{"id":18822,"library":"startupdb","title":"startupDB","description":"A file-based database for Express.js applications. Its current stable version is 3.0.19. It stores data in JSON files on the filesystem, making it suitable for small projects or prototyping where a full database is unnecessary. Key differentiators include zero configuration, automatic file management, and tight integration with Express routing. It is released as needed on npm with no fixed cadence. Compared to alternatives like lowdb, startupDB offers simpler file handling and is specifically designed to work as middleware for Express.","status":"active","version":"3.0.19","language":"javascript","source_language":"en","source_url":"https://github.com/bitsplitter/startupDB","tags":["javascript"],"install":[{"cmd":"npm install startupdb","lang":"bash","label":"npm"},{"cmd":"yarn add startupdb","lang":"bash","label":"yarn"},{"cmd":"pnpm add startupdb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"startupDB is designed as middleware for Express.js applications","package":"express","optional":false}],"imports":[{"note":"CommonJS module; no ES module version available.","wrong":"import startupDB from 'startupdb'","symbol":"startupDB","correct":"const startupDB = require('startupdb')"},{"note":"Call startupDB as a function to initialize the middleware.","wrong":"app.use(startupDB)","symbol":"startupDB()","correct":"app.use(startupDB())"},{"note":"The database instance is attached to req.db by default.","wrong":"req.startupDB.get('users')","symbol":"req.db","correct":"req.db.get('users')"}],"quickstart":{"code":"const express = require('express');\nconst startupDB = require('startupdb');\n\nconst app = express();\nconst PORT = process.env.PORT || 3000;\n\napp.use(startupDB());\n\napp.get('/users', (req, res) => {\n  const users = req.db.get('users') || [];\n  res.json(users);\n});\n\napp.post('/users', (req, res) => {\n  const user = req.body;\n  req.db.push('users', user);\n  res.status(201).json(user);\n});\n\napp.listen(PORT, () => {\n  console.log(`Server running on port ${PORT}`);\n});","lang":"javascript","description":"Sets up Express with startupDB middleware, demonstrating GET and POST routes to interact with a file-based 'users' collection."},"warnings":[{"fix":"Use a proper database like MongoDB or PostgreSQL for scalable applications.","message":"The database file operation is synchronous and blocking. Avoid using startupDB in production with high concurrency.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to version 3.0.0 or later, or call `req.db.save()` after pushes.","message":"Data is not automatically persisted after each write; you may need to call `req.db.save()` after modifications.","severity":"gotcha","affected_versions":"<3.0.0"},{"fix":"Replace `req.startupDB` with `req.db` as of v3.","message":"In v2, `req.startupDB` was used instead of `req.db`. This is a breaking change.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Explicitly pass a configuration object with a `dataPath` property.","message":"The `startupDB` function without arguments uses a default data directory './data'. This may be deprecated in future versions.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install startupdb`.","cause":"Package not installed in node_modules.","error":"Cannot find module 'startupdb'"},{"fix":"Use `const startupDB = require('startupdb')` instead of `import`.","cause":"Using ES module import syntax with CommonJS package.","error":"TypeError: startupDB is not a function"},{"fix":"Ensure `app.use(startupDB())` is called with parentheses.","cause":"StartupDB middleware not initialized or called incorrectly.","error":"TypeError: Cannot read properties of undefined (reading 'get')"},{"fix":"Create the directory or configure a custom `dataPath` in startupDB options.","cause":"The default data directory does not exist.","error":"Error: ENOENT: no such file or directory, open './data/startupdb.json'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}