Skip to content

Repository files navigation

Decku API

A Node.js RESTful API built with TypeScript, Express, Zod, and MongoDB for managing steamdeck game settings DB.

codecov

Prerequisites

  • Node.js (v20 or higher)
  • MongoDB (running locally or remote)

Installation

  1. Install dependencies:
npm install
  1. Create a .env file based on .env.example:
cp .env.example .env
  1. Update the .env file 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

Development

Run the development server with hot reload:

npm run dev

Testing

This project uses Vitest and Supertest with an in-memory MongoDB instance (mongodb-memory-server) for integration tests.

Test Strategy

  • 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 tests

Run all tests:

npm test

Run in watch mode:

npm run test:watch

Run with coverage:

npm run test:coverage

Run a specific test file pattern:

npm test -- game

Coverage goals

  • Statements: > 90%
  • Branches: > 85%
  • Functions: > 90%
  • Lines: > 90%

Build

Compile TypeScript to JavaScript:

npm run build

Production

Run the compiled JavaScript:

npm start

Run the single queue worker (in a separate process/container):

npm run worker

Docker

Build the Docker image:

docker build -t decku-api .

Run the Docker container:

docker run -d -p 3000:3000 --env-file .env decku-api

DB Backups

Use 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 dump

You 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 30

You 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 restore

License

MIT

About

An API that allows you to query a DB with collected community reports about game performance and best settings on the steam deck hardware.

Topics

Resources

Stars

Watchers

Forks

Used by

Contributors

Languages