A Node.js RESTful API built with TypeScript, Express, Zod, and MongoDB for managing steamdeck game settings DB.
- Node.js (v20 or higher)
- MongoDB (running locally or remote)
- Install dependencies:
npm install- Create a
.envfile based on.env.example:
cp .env.example .env- Update the
.envfile with your MongoDB connection string:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/decku
MONGODB_DATABASE=decku
SESSION_SECRET=your_current_secret_here,optional_old_secret_for_rotation
Run the development server with hot reload:
npm run devThis project uses Vitest and Supertest with an in-memory MongoDB instance (mongodb-memory-server) for integration tests.
- Full request/response integration coverage
- Input validation coverage (Zod)
- Database query and error-path coverage
- Complex payload and edge-case coverage
- Deterministic CI-friendly execution (no external MongoDB dependency)
Tests follow the AAA pattern:
- Arrange: set up data/mocks
- Act: execute endpoint behavior
- Assert: verify response and side effects
Run all tests:
npm testRun in watch mode:
npm run test:watchRun with coverage:
npm run test:coverageRun a specific test file pattern:
npm test -- game- Statements: > 90%
- Branches: > 85%
- Functions: > 90%
- Lines: > 90%
Compile TypeScript to JavaScript:
npm run buildRun the compiled JavaScript:
npm startRun the single queue worker (in a separate process/container):
npm run workerBuild the Docker image:
docker build -t decku-api .Run the Docker container:
docker run -d -p 3000:3000 --env-file .env decku-apiUse mbs3 package to create a backup of the MongoDB database and upload it to an S3 bucket.
Make sure you have these environment variables set in your .env file:
MONGODB_DATABASE=db
MONGODB_URI='mongodb://localhost:27017'
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
S3_BUCKET=your-backup-bucket
S3_PREFIX=backups/mongodb
AWS_ENDPOINT=https://your-custom-endpoint.com
Then run the following command to create a backup and upload it to S3:
npx mbs3 dumpYou can remove older backups from S3 using the mbs3 prune command, which deletes backups older than a specified number of days:
npx mbs3 prune --days 30You can restore a backup from S3 using the mbs3 restore command, which downloads the latest backup and restores it to your MongoDB instance:
npx mbs3 restoreMIT