- TypeScript 98.8%
- JavaScript 0.6%
- Dockerfile 0.3%
- Makefile 0.2%
|
|
||
|---|---|---|
| .gitea | ||
| docs | ||
| src | ||
| tests | ||
| .editorconfig | ||
| .env.sample | ||
| .gitignore | ||
| .prettierrc | ||
| .swcrc | ||
| Dockerfile | ||
| dockerignore | ||
| eslint.config.ts | ||
| LICENSE | ||
| makefile | ||
| nest-cli.json | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| start.sh | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
Monorepo
Monorepo for monsters
TLDR:
1. How to start
- Copy .env.sample to .env
cp .env.sample .env
and fill it will your options. You can find out more in How to start
- Install dependencies
npm install
- Initialize database
npm run migrate
- Start
npm run start:dev
Above scripts will let you start this application. You can find more detailed guide in /docs/HowToStart.md
2. How to build
npm run build / yarn build
Important
If you even encounter strange build behavior, tsconfig is set to create build with cache. Set option
incrementalin tsConfig to false
3. Useful information
3.1 Testing
All test currently are written using jest. You can run all tests or just type specific tests
Available targets
yarn test:e2e = run 'end to end' tests
yarn test:unit = run 'unit' tests
Tip
To run all tests, use makefile script
make test
3.2 Hooks
Instead of adding additional packages like husky, its easier to add hooks manually. If you want your code to check its quality and test itself before committing code, you can add this code to .git/hooks/pre-commit
#!/bin/sh
set -e
echo "Running lint-staged"
npm run lintStaged
echo "Running tsc"
npm run listErrors
echo "Running unit tests"
npm run test:unit
echo "Running e2e tests"
npm run test:e2e
echo "Auditing"
npm audit
Above code will:
- Lint your staged code
- Validate if it can be built
- Test it
- Audit it
Most of people that I've meet, do not care about auditing their code. If you do not care if packages includes in your app have known vulnerabilities, you can remove last 2 lines from this code. Keep in mind, that pipelines also run the same commands.
Tip
If you are not using windows, you should make above file executable by
chmod +x ./git/hooks/pre-commit.
4. Docs
4.1 Environments
This application utilizes NODE_ENV env, which is set in package.json. start command does not include NODE_ENV. This is prepared for docker or any external tools, to manipulate environment.
- Production - prod env. This is the env you want, if you are planning on running production env. This mode disables debug logs.
- Development - development settings. If you are working on this application, thats the mode you want.
- Test - test env, set while running tests. This env will make so mysql connects to testing database.
4.2 Api docs
This project is using swagger docs for api documentation. You can access them by route http://localhost:{port}/docs
4.3 Probes
This application is ready for probing in k8s / other systems. You can find liveness probe in here. Readiness probe should be utilized based on /api/health route. This route will not respond, if server is dead. This will fail only if there is a heavy problem with database connection or application is unable to start, due to problems other problems.
4.4 Sigterm, Sigint
This application uses handlers for sigint and sigterm. Based on those, it will simply close connections, nest application and will exit. Please remember, that there is no proper handler for this yet.
4.5 Tests
This application has tests written in jest. Additional docs:
4.6 Additional docs
Simplified application startup Pipelines
Additional docs can be found in docs folder
5. Style
This application uses my personal eslint settings. They are EXTREMELY strict and will force you to write specific type of code with unified style across whole project. This is MY config. You may not like it so please, modify it to your heart desire.