- typescript
- docker compose
- express REST API with swagger
- postgres database + sequelize
- eslint + husky + lint-staged checks
- JSON schemas
- API tests based on axios + schema validation
- Create
env
folder in the root project folder - Create
env/.env.development
andenv/.env.production
files - Add needed environment variables, see example env file.
Make sure POSTGRES_DB has different names fordevelopment
andproduction
.
Make sure POSTGRES_PASSWORD variable is changed. - Run docker-compose commands
Dev environment:npm run dc:dev
Production environment:npm run dc:prod
Dev environment only:
Apply: npm run db:migrate
Undo: npm run db:migrate:undo
To create a new migration please use:
npx sequelize-cli migration:create --name=<MIGRATION_NAME
Dev environment only:
Apply: npm run db:seed:all
Undo: npm run db:seed:undo
Use case: if you need to recreate table with a lot of relations.
- Search for the volume:
docker volume ls
- Remove volume "online-school-app_pg-data":
docker volume rm online-school-app_pg-data
- Run app:
npm run dc:dev
- database will be created from scratch
If it's the first run please execute the command: npm run db:seed:all
It'll create all data needed for tests.
Dev mode: npm test
CI mode: npm run test:nowatch
- Update
UserRoles
enum in user model - Add permissions to user in this file
- Permissions for roles will be updated with
InitialDbSeed
function on app start
To covert DOCS.md to pdf please do the following:
- Install this package globally
npm i -g md-to-pdf
- Run
cat DOCS.md | md-to-pdf > ./pdf/online-school-api-docs.pdf
- Upload PDF wherever you want
Please do not add PDF file to git.