Skip to content
atarashi
Documentation menu

MongoDB REST API

Express + MongoDB + Mongoose + JWT + Docker, in strict TypeScript.

atarashi new my-app --preset backend-mongo

What you get

Files

31 files, 19.3 KB before node_modules.

my-app/
├── .github/
│   └── workflows/
│       └── ci.yml
├── src/
│   ├── config/
│   │   └── env.ts
│   ├── db/
│   │   └── index.ts
│   ├── lib/
│   │   ├── async-handler.ts
│   │   ├── http-error.ts
│   │   ├── http.ts
│   │   ├── jwt.ts
│   │   └── password.ts
│   ├── middlewares/
│   │   ├── auth.ts
│   │   └── error-handler.ts
│   ├── models/
│   │   └── user.ts
│   ├── routes/
│   │   └── index.ts
│   ├── app.ts
│   └── index.ts
├── tests/
│   └── health.test.ts
├── .dockerignore
├── .editorconfig
├── .env.example
├── .gitignore
├── .prettierignore
├── .prettierrc.json
├── Dockerfile
├── LICENSE
├── README.md
├── atarashi.json
├── docker-compose.yml
├── eslint.config.mjs
├── package.json
├── pnpm-workspace.yaml
├── tsconfig.json
└── vitest.config.ts

Dependencies

  • bcryptjs@^3.0.2
  • cookie-parser@^1.4.7
  • cors@^2.8.5
  • dotenv@^17.4.2
  • express@^4.21.2
  • helmet@^8.1.0
  • jsonwebtoken@^9.0.2
  • mongoose@^8.19.0
  • morgan@^1.10.1
  • zod@^3.25.76

Development only:

  • @eslint/js@^9.37.0
  • @types/bcryptjs@^3.0.0
  • @types/cookie-parser@^1.4.9
  • @types/cors@^2.8.19
  • @types/express@^4.17.23
  • @types/jsonwebtoken@^9.0.10
  • @types/morgan@^1.9.10
  • @types/node@^22.19.0
  • @types/supertest@^6.0.3
  • @vitest/coverage-v8@^3.2.4
  • eslint@^9.37.0
  • eslint-config-prettier@^10.1.8
  • prettier@^3.6.2
  • supertest@^7.1.4
  • tsx@^4.20.6
  • typescript@^5.9.3
  • typescript-eslint@^8.45.0
  • vitest@^3.2.4

After generating

  1. Start the dev server: pnpm run dev
  2. Copy .env.example to .env and fill in the blanks
  3. Start MongoDB: pnpm run db:up
  4. Set MONGODB_URI in .env
  5. Add your models under src/models/
  6. Check the API: curl http://localhost:3000/health
  7. Generate a signing key: openssl rand -hex 32
  8. Put it in .env as JWT_SECRET
  9. Build the image: docker build -t my-app .
  10. Bring the stack up: pnpm run compose:up
  11. Lint the project: pnpm run lint
  12. Run the tests: pnpm run test
  13. Tests read the same environment as the app, so export your .env before running them
  14. Push a branch and open a pull request to see CI run
  15. Fill in the blank values in .env.example and copy it to .env

Change it

A preset is a starting point, not a cage. Add to it, drop from it, or eject:

atarashi new my-app --preset backend-mongo --add obs/pino
atarashi new my-app --preset backend-mongo --remove lint/biome --add lint/eslint-prettier
atarashi add auth/jwt   # later, inside the generated project

Part of the atarashi documentation, written and maintained by Gautam Suthar.