{"id":43404,"library":"nd5-mongodb-server","title":"nd5-mongodb-server","description":"Dynamic Express server with MongoDB and WebSocket support. Version 1.7.2. Provides a rapid-development framework by auto-loading controllers from a file system path and connecting them to MongoDB collections via a helper function. Includes Socket.IO integration for real-time communication. Written in TypeScript with included type definitions. Compared to alternatives like FeathersJS or Sails, this is a minimal, convention-based approach with fewer abstractions, targeting small to medium projects where quick setup is desired.","status":"active","version":"1.7.2","language":"javascript","source_language":"en","source_url":"https://github.com/evandroneder/nd5-mongodb-server","tags":["javascript","express","mongodb","server","api","rest","realtime","websocket","websockets","typescript"],"install":[{"cmd":"npm install nd5-mongodb-server","lang":"bash","label":"npm"},{"cmd":"yarn add nd5-mongodb-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add nd5-mongodb-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core HTTP framework for routing and middleware","package":"express","optional":false},{"reason":"MongoDB driver for database operations","package":"mongodb","optional":false},{"reason":"WebSocket library for real-time bidirectional event-based communication","package":"socket.io","optional":false}],"imports":[{"note":"ESM default export? Actually named export. CommonJS require works but might miss types.","wrong":"const StartServer = require('nd5-mongodb-server')","symbol":"StartServer","correct":"import { StartServer } from 'nd5-mongodb-server'"},{"note":"Mistyped function name 'getColletion' (should be 'getCollection'?). Also path must be '/mongo' subpath export.","wrong":"import { getColletion } from 'nd5-mongodb-server'","symbol":"getColletion","correct":"import { getColletion } from 'nd5-mongodb-server/mongo'"},{"note":"Socket.IO v3+ removed namespace exports; use named import or direct from 'socket.io'.","wrong":"import * as SocketIO from 'socket.io'; const io: SocketIO.Server = ...","symbol":"SocketIO.Server","correct":"import { Server as SocketIOServer } from 'socket.io'; import { StartServer } from 'nd5-mongodb-server'"}],"quickstart":{"code":"import { StartServer } from 'nd5-mongodb-server';\nimport * as path from 'path';\n\nconst dbs = [\n  { db: { name: 'test', collections: ['cars'] } },\n];\n\nconst mongodb = 'mongodb+srv://' + (process.env.MONGO_USER ?? '') + ':' + (process.env.MONGO_PASS ?? '') + '@cluster.mongodb.net/test?retryWrites=true&w=majority';\n\nStartServer({\n  middleWare: (req: any, res: any, next: any) => next(),\n  socketServer: (io: any) => {\n    io.on('connection', (client: any) => {\n      console.log('Client connected');\n      client.on('message', (data: any) => io.emit('message', data));\n    });\n  },\n  controllersPath: path.join(__dirname, 'controllers'),\n  mongoDB: {\n    url: mongodb,\n    useNewUrlParser: true,\n    useUnifiedTopology: true,\n    dbs: dbs\n  }\n});","lang":"typescript","description":"Sets up an Express server with MongoDB connection and WebSocket support, auto-loading controllers from a folder."},"warnings":[{"fix":"Use exact spelling 'getColletion' as exported. Do not correct to 'getCollection'.","message":"Function name 'getColletion' is misspelled (should be 'getCollection'). Expect typo-induced errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use destructuring: const { collection } = getColletion({...});","message":"getColletion returns an object with 'collection' property, not the collection directly. Typos in property access cause undefined errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Omit these options in MongoDB driver v5+ or set them explicitly if needed for compatibility.","message":"useNewUrlParser and useUnifiedTopology are deprecated in newer MongoDB driver versions.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Update middleware types to Express v5 signatures: (req: Request, res: Response, next: NextFunction) => void.","message":"In Express v5, req/res types changed; middleware signatures may break TypeScript compilation.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use socket.io v2 types or adapt to v3: import { Server } from 'socket.io' and type the parameter as Server.","message":"SocketServer parameter type is SocketIO.Server which only exists in socket.io v2; v3+ uses 'Server' type from 'socket.io' package.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'1.7.2':14 'abstract':73 'altern':58 'api':88 'approach':70 'auto':23 'auto-load':22 'base':69 'collect':36 'communic':48 'compar':56 'connect':32 'control':25 'convent':68 'convention-bas':67 'definit':55 'desir':83 'develop':19 'dynam':5 'express':6,85 'feathersj':60 'fewer':72 'file':28 'framework':20 'function':40 'helper':39 'includ':41,53 'integr':43 'javascript':84 'like':59 'load':24 'medium':77 'minim':66 'mongodb':3,9,35,86 'nd5':2 'nd5-mongodb-server':1 'path':30 'project':78 'provid':15 'quick':80 'rapid':18 'rapid-develop':17 'real':46 'real-tim':45 'realtim':90 'rest':89 'sail':62 'server':4,7,87 'setup':81 'small':75 'socket.io':42 'support':12 'system':29 'target':74 'time':47 'type':54 'typescript':51,93 'version':13 'via':37 'websocket':11,91,92 'written':49","created_at":"2026-06-05T16:59:38.650848+00:00","updated_at":"2026-06-05T16:59:38.650848+00:00","problems":[{"fix":"Ensure the object passed to getColletion has 'collection' (string) and 'db' (string) properties.","cause":"Invalid arguments to getColletion: missing collection name or db name.","error":"TypeError: Cannot destructure property 'collection' of 'getColletion(...)' as it is undefined."},{"fix":"Change import to: import { getColletion } from 'nd5-mongodb-server/mongo';","cause":"Import path is wrong; must use 'nd5-mongodb-server/mongo' not 'nd5-mongodb-server/src/mongo'.","error":"Error: Cannot find module 'nd5-mongodb-server/mongo'. Please verify that the package.json has a valid \"main\" entry."},{"fix":"Use 'import { Server } from 'socket.io'' and type the socketServer parameter as 'Server'.","cause":"Socket.IO v3+ does not export SocketIO.Server; instead use 'Server' from 'socket.io'.","error":"Type 'SocketIO.Server' is not assignable to type 'Server'."},{"fix":"Remove those options from the mongoDB config object.","cause":"MongoDB driver v5+ removed useNewUrlParser and useUnifiedTopology options.","error":"Property 'useNewUrlParser' does not exist on type 'MongoClientOptions'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/evandroneder/nd5-mongodb-server#readme","github":"https://github.com/evandroneder/nd5-mongodb-server","docs":null,"changelog":null,"pypi":null,"npm":"nd5-mongodb-server","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}