Welcome to the Nest repository.
Make sure you have the following requirements installed before getting started:
Node.js
(version^20.15
|^18.10
)pnpm
(version^9.0
)
Note
To use pnpm
, simply run the corepack enable
command (make sure to have Node.js
installed beforehand). Refer to here for more information.
- Framework: Nest JS (version
^10.0
) - Database: Postgres (version
^16.0
)
Make a copy of the .env.example
file in the current directory and rename it to .env
.
cp .env.example .env
This file initializes environment variables containing configurations needed to start the application. These variables are as follows:
PORT
: The port on which the server listens for connectionsCORS_ALLOWED_ORIGINS
: A list of allowed origins for CORS requestDB_USER
: The username to connect to the databaseDB_PASSWORD
: The password to connect to the databaseDB_HOST
: The address of the host where the database is locatedDB_PORT
: The port on which the database server is listeningDB_NAME
: The name of the database to connectDATABASE_URL
: The connection URL for Prisma ORMJWT_SECRET
: The secret key used to sign and verify JWTNODE_ENV
: The environment in which the application is running
Check if Postgres is installed. If not, you can easily create it with Docker by running the command:
docker compose up -d
Note
Make sure Docker is installed to run the docker compose up -d
command.
Install project dependencies by running the following command:
pnpm install
Create the database and automatically insert test data by running the following command:
pnpm db:migrate:dev
Important
- Ensure that the database connection string is correctly set in the
DATABASE_URL
variable in the.env
file. - If test data is not inserted automatically, run the
pnpm db:seed
command to insert it manually.
Run the server in development mode
pnpm start:dev
Run the server in production mode
pnpm start:prod