Skip to content

Demonstrates a NodeJS API project, structured for a good developer experience

License

Notifications You must be signed in to change notification settings

mykeels/rest-api-ioc-demo

Repository files navigation

Rest API IoC Demo

Written to demonstrate how API projects built with NodeJS can be structured for a much better developer experience than is usually seen in the wild.

This API will demonstrate:

  • Proper Dependency Inversion
    • Every service is independent of other services
    • No service imports another.
  • Proper folder structure
    • Code is grouped according to business domains.
    • Only common logic lives outside this heirarchy, in a common folder.
  • Inversion of Control (IoC)
    • Instead of depending directly on another service, all dependencies are on abstractions, serviced by an IoC container.
  • OpenAPI schema is accurately auto-generated
  • Use gherkin specifications for End-to-end (E2E) tests

Setup Locally

Run:

docker-compose up -d # to start the mongodb server
pnpm i
pnpm generate:routes # to generate the API routes and OpenAPI spec in dist/swagger.json
pnpm db:seed # to seed the DB
pnpm dev # to run the server

Development

Everytime you make a change, you need to run pnpm generate:routes to ensure the new tsoa routes are updated.

Testing

This project relies on End-to-end (E2E) tests, which can be run with:

pnpm e2e

About

Demonstrates a NodeJS API project, structured for a good developer experience

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published