Example Server example. Authentication using passport and passport-jwt. Docker Containerization
Clone the repository https://github.com/johnwayodi/nest-passport-jwt-example.git
$ git clone https://github.com/johnwayodi/nest-passport-jwt-example.git
$ cd nest-passport-jwt-example && yarn installThe application uses PostgreSQL as the database provider.
Create a .env.development file on the root folder of the project.
file and set the variables accordingly
APP_PORT=
APP_SECRET=
DB_HOST=
DB_NAME=
DB_USERNAME=
DB_PASSWORD=
DB_PORT=# development
$ yarn start:dev
# watch mode
$ yarn start:debug
# production mode
$ yarn start:prodCreate a .env file and set the appropiate variables for production server.
#production variables
NODE_ENV=
APP_PORT=
APP_SECRET=
DB_HOST=
DB_NAME=
DB_USERNAME=
DB_PASSWORD=
DB_PORT=
# Docker Stuff
COMPOSE_PROJECT_NAME=
APP_CONTAINER_NAME=
APP_IMAGE_NAME=
DB_CONTAINER_NAME=To create all containers and run production ready app, ensure Docker is installed.
On the projects root, run the following command:
# production server
$ docker-compose upOnce the server is started, documentation for the API is available on localhost:{APP_PORT}/apidocs
Create a .env.testing file and set the appropiate variables for testing server using format of the sample environment file.
# unit tests
$ yarn test
# e2e tests
$ yarn test:e2e
# test coverage
$ yarn test:cov