Skip to content

lazyskulptor/express-template

Repository files navigation

Node.JS Express Template with Mikro-ORM

Main dependent Library

  • mikro-orm for persistance layer and documentation
  • tsoa for presentation layer
  • module-alias to manage modules
  • jest for unit test
  • supertest for e2e test

Run Application

Run and configure application

  • Create and configure .env file for local environment
    • To run with sqlite, please refer .env.test file
    • To run with mysql, check mysql service is running and configure like .env.dev file
  • All configurations for Database are applied in file repo-context.ts
  • Now app can be run with below command
npm run dev:start

Migrate Database

  • Migration is triggered in index.ts or global-suite.ts files
  • Sqlite migration files are always created with initialized option and won't be saved
  • With MySQL, migration file must be created manually, When definetion of entities or decorators are changed
# Only at first time
npx mikro-orm migration:create --initial

npx mikro-orm migration:create

Routers

Note
routes.ts, swagger.json files are generaged with tsoa library.
When files aren't generaged, app.ts file would errors.
For example when just download this project.
Then build or generate with commands npm run build or npm run routes