- Clone this repository and open it
$ git clone https://github.com/z1-lab/nestjs-backend-template
$ cd nestjs-backend-template- Install dependencies
$ yarn- Create a copy of the
.env.developmentfile and call it.env. Update the environment variables to match your current environment.
$ cp .env.development .env- Launch a PostgreSQL database with docker, it will use the port defined in the
DB_PORTvar.
$ docker-compose up- Generate the prisma client
$ yarn prisma generate- Create the database model
$ yarn prisma migrate up --experimental- Launch the dev mode
$ yarn dev- If you're going to edit the GraphQL schema, run the following command to regenerate the TypeScript types.
$ yarn gql:typings --watchyarn dev. Runs the project in dev mode, which means that it won't check types and will restart with every change you make.yarn build. Compiles the project to the./distfolder.yarn typecheck. Checks the typings of the project. Gets executed before trying to create a new commit but you can also run it manually.yarn start. Runs the compiled program. Remember to executeyarn buildbefore attempting to launch the program.yarn lint. Runs ESLint. You can append--fixin order to fix autofixable issues.yarn gql:typings. Watches for changes in the GraphQL files and regenerates thesrc/graphql.tsfile.yarn test. Launch the test suite.yarn test:debug. Launch the test suite in debug mode. You'll need to run all the tests at least one time before trying to set any breakpoint.
You can attach a debugger to the Node.js instance that runs when you're using either yarn dev or yarn test:debug.
Place this in your .vscode/launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"restart": true,
"processId": "${command:PickProcess}",
"localRoot": "${workspaceFolder}",
"remoteRoot": ".",
"sourceMaps": true,
"skipFiles": ["<node_internals>/**"]
}
]
}