This guide helps you migrate from original Deployd (discontinued 2019) to this modernized fork. The fork maintains backward compatibility where possible while introducing breaking changes for Node.js 22 and MongoDB 6+ support.
| Aspect | Original Deployd | This Fork |
|---|---|---|
| Node.js | 4.x - 14.x | 22.x LTS+ |
| MongoDB | 2.x - 4.x | 6.0+ |
| Socket.IO | 1.7.4 | 4.8.1 |
| MongoDB Driver | < 4.0 | 6.10.0 |
The old db.host/port/name/credentials pattern is deprecated. Use connectionString + connectionOptions instead.
Old Pattern (still works but deprecated):
var server = deployd({
db: {
host: 'localhost',
port: 27017,
name: 'mydb',
credentials: {
username: 'user',
password: 'pass'
}
}
});New Pattern (recommended):
var server = deployd({
db: {
connectionString: 'mongodb://user:pass@localhost:27017/mydb',
connectionOptions: {
serverSelectionTimeoutMS: 30000,
connectTimeoutMS: 30000,
socketTimeoutMS: 30000,
tls: true, // Required for managed services
minPoolSize: 10,
maxPoolSize: 100
}
}
});MongoDB Atlas Example:
db: {
connectionString: process.env.MONGODB_URI, // mongodb+srv://...
connectionOptions: {
tls: true,
serverSelectionTimeoutMS: 30000
}
}Migration Steps:
- Convert your connection details to a MongoDB connection string
- Add
connectionOptionswith TLS settings for managed MongoDB - Test connection before deploying
File Reference: lib/db.js:159-179 (getConnection), lib/db.js:204-215 (connectionOptions)
Socket.IO v4 requires explicit CORS configuration. The old implicit CORS is no longer available.
Old Pattern (no explicit CORS):
var io = require('socket.io').listen(server, {'log level': 0});New Pattern (explicit CORS):
var io = require('socket.io')(server, {
cors: {
origin: "*", // Or specific domains
methods: ["GET", "POST"]
},
transports: ['websocket', 'polling']
});Migration Steps:
- Add CORS configuration to all Socket.IO initialization code
- Update
socket.roomsreferences (now a Set, useArray.from(socket.rooms)) - Test WebSocket connections
File Reference: lib/server.js:69-78
These npm modules are now built-in and should be removed from package.json:
dpd-event→ Native Event resource (lib/resources/event.js)dpd-clientlib→ Native (lib/clientlib.js + lib/clib/)dpd-dashboard→ Native (lib/dashboard.js + lib/dashboard/)dpd-count→ Integrated into Collection (lib/resources/collection/index.js:895-962)
Migration Steps:
- Remove these packages from
package.jsondependencies - Remove any
npm install dpd-eventinstructions from documentation - No code changes needed - modules are auto-loaded
Four dangerous MongoDB operators are now blocked for security:
$where- JavaScript execution on server$function- JavaScript in aggregation$accumulator- Custom JavaScript aggregation$expr- Can contain$function
All other MongoDB operators are supported.
If you used these operators, you must:
- Rewrite queries to use safe MongoDB operators
- Move JavaScript logic to event scripts
- Test thoroughly
File Reference: lib/resources/collection/index.js:143-162
Available automatically - no configuration needed:
curl http://localhost:3000/__health/live
curl http://localhost:3000/__health/ready
curl http://localhost:3000/__health/startupUse in Kubernetes/Docker health checks.
Documentation: Production Deployment
Available automatically at /metrics:
curl http://localhost:3000/metricsDocumentation: Monitoring & Observability
JSON-formatted logs for production:
// Automatically enabled when NODE_ENV=production
{
"timestamp": "2024-11-09T10:30:00.000Z",
"level": "info",
"message": "Server listening",
"requestId": "req-abc123"
}Set log level with LOG_LEVEL environment variable.
Create Event resources directly from the dashboard:
// resources/webhook/config.json
{
"type": "Event"
}Supports: GET, POST, PUT, PATCH, DELETE, beforeRequest
Documentation: Event Resource
All collections automatically have /count endpoint:
// HTTP
GET /todos/count?completed=true
// Response: {"count": 42}
// dpd.js
dpd.todos.get('count', {completed: true}, function(result) {
console.log(result.count);
});Documentation: Count Endpoint
SIGTERM/SIGINT handling for zero-downtime deployments:
process.on('SIGTERM', () => {
server.close(() => process.exit(0));
});Automatically closes database connections and stops accepting new requests.
File Reference: lib/server.js:245-256
-
Backup your application and database
mongodump --uri="mongodb://localhost:27017/mydb" --out=backup/ -
Update Node.js to 22.x LTS
nvm install 22 nvm use 22 node --version # Should be 22.x -
Update package.json dependencies
{ "dependencies": { "deployd": "github:nalyk/deployd", "mongodb": "^6.10.0", "socket.io": "^4.8.1" } }Remove:
"dpd-event": "*", "dpd-clientlib": "*", "dpd-dashboard": "*", "dpd-count": "*"
-
Install dependencies
rm -rf node_modules package-lock.json npm install
-
Update database configuration
Option A: Environment variable (recommended)
# .env MONGODB_URI=mongodb://localhost:27017/mydb NODE_ENV=production// production.js var server = deployd({ db: { connectionString: process.env.MONGODB_URI, connectionOptions: { serverSelectionTimeoutMS: 30000, tls: false // true for managed services } } });
Option B: Direct configuration
var server = deployd({ db: { connectionString: 'mongodb://localhost:27017/mydb', connectionOptions: { serverSelectionTimeoutMS: 30000 } } });
-
Update Socket.IO configuration (if using attach())
// Old var io = require('socket.io').listen(server, {'log level': 0}); // New var io = require('socket.io')(server, { cors: { origin: "*", methods: ["GET", "POST"] }, transports: ['websocket', 'polling'] });
-
Test locally
node development.js # Visit http://localhost:2403/dashboard # Test API endpoints
-
Test with production MongoDB
MONGODB_URI="mongodb+srv://..." node development.js -
Update deployment scripts
Add health checks to Docker/Kubernetes manifests (see Production Deployment).
-
Deploy to staging environment
# Test thoroughly before production -
Deploy to production
# Use blue-green or rolling deployment
Start fresh with the modernized fork:
# Clone example-app structure
git clone https://github.com/nalyk/deployd.git
cd deployd/example-app
# Copy and configure
cp .env.example .env
# Edit .env with your MongoDB URI
# Install and run
npm install
npm startBefore deploying to production, verify:
- Server starts without errors
- Dashboard loads and authenticates
- Collections CRUD operations work
- User authentication works (if using UserCollection)
- Event scripts execute correctly
- WebSocket connections work (if using
dpd.on()) - Health checks respond:
-
/__health/livereturns 200 -
/__health/readyreturns 200 when DB connected -
/__health/startupreturns 200 after startup
-
- Metrics endpoint works:
/metrics - Graceful shutdown works (SIGTERM)
- Production MongoDB connection succeeds
- TLS connections work (for managed MongoDB)
- Performance is acceptable under load
If migration fails:
-
Restore original Deployd
npm install deployd@0.8.10 # Or your previous version npm install dpd-event dpd-clientlib dpd-dashboard -
Restore old configuration
db: { host: 'localhost', port: 27017, name: 'mydb' }
-
Downgrade Node.js (if needed)
nvm use 14
-
Restore from backup
mongorestore --uri="mongodb://localhost:27017" backup/
Cause: Using dpd-event npm package instead of native Event resource.
Solution: Remove dpd-event from package.json and reinstall:
npm uninstall dpd-event
rm -rf node_modules package-lock.json
npm installCause: Port already bound by another process.
Solution:
# Find process
lsof -i :2403
# Kill process
kill -9 <PID>
# Or use different port
PORT=3000 node development.jsCause: MongoDB not reachable or TLS not configured.
Solution:
db: {
connectionString: process.env.MONGODB_URI,
connectionOptions: {
serverSelectionTimeoutMS: 60000, // Increase timeout
tls: true, // Enable for managed MongoDB
tlsAllowInvalidCertificates: true
}
}Cause: Missing CORS configuration in Socket.IO v4.
Solution:
socketIo: {
options: {
cors: {
origin: "*", // Or specific domain
methods: ["GET", "POST"]
}
}
}Cause: This was a bug in earlier versions of this fork, now fixed.
Solution: Update to latest version of this fork.
- Issues: https://github.com/nalyk/deployd/issues
- Original Docs: http://docs.deployd.com (for reference only)
- MongoDB Driver Docs: https://www.mongodb.com/docs/drivers/node/current/
| This Fork | Node.js | MongoDB | Socket.IO | MongoDB Driver |
|---|---|---|---|---|
| 1.2.0+ | 22+ | 6.0+ | 4.8.1 | 6.10.0 |
| 1.1.0 | 22+ | 6.0+ | 4.8.0 | 6.9.0 |
| 1.0.0 | 22+ | 6.0+ | 4.7.0 | 6.8.0 |
| Original | Node.js | MongoDB | Socket.IO | MongoDB Driver |
|---|---|---|---|---|
| 0.8.10 | 4-14 | 2-4 | 1.7.4 | 2.x |