cp .env.example .env && yarn && docker-compose down && docker-compose up -d && sleep 7 && yarn prisma:generate && yarn build
# restart DB
docker-compose down && docker-compose up -d && docker-compose logs -f
# development
yarn start
# watch mode
yarn start:dev
# production mode
yarn start:prod
# unit tests
yarn test
# e2e tests
yarn test:e2e
# test coverage
yarn test:cov
curl --request POST 'http://localhost:8942/api/user/create' \
-H 'content-type: application/json' \
--data-raw '{"email": "baakey@21times2.com", "username": "baakey"}'
curl 'http://localhost:8942/api/user/all?email=baakey@21times2.com' --compressed
The Patterns Behind Scalable, Reliable, and Performant Large-Scale Systems
- How to create new files ?
npx nest generate --help
- How to run db migrations ?
npx prisma migrate --help
- How to connect to the local database from terminal ?
PGPASSWORD=postgres psql -h 127.0.0.1 -p 5442 -d dtk -U postgres
- How to use
StandardDtkApiResponse
?
// Response with data
const responseWithData: StandardDtkApiResponse<{ message: string }> = {
data: { message: 'hello' },
error: null,
};
// Response with error
const responseWithError: StandardDtkApiResponse<null, { code: number, message: string }> = {
data: null,
error: { code: 404, message: 'not found' },
};
// Response with data and error
const responseWithDataAndError: StandardDtkApiResponse<
{ message: string, id: number },
{ code: number, message: string, details: Record<string, any> }
> = {
data: { message: 'hello', id: 123 },
error: { code: 500, message: 'server error', details: { foo: 'bar' } },
};