Skip to content

Example NestJS backend with some basic functionality

License

Notifications You must be signed in to change notification settings

vatolvan/nest-test

Repository files navigation

NestJS backend with user registration and login handling using JWT tokens. Ready to deploy to Heroku.

Build step will create ormconfig from environment variables (DATABASE_URL) or default config which will be used to connect to a database.

Installation

$ npm install

Database

Project includes docker-compose for starting postgres container for easier start. Navigate to postgres folder and start the container with

docker-compose up -d

Database is run on post 5433 as opposed to default postgres port of 5432. Run the database migrations before trying to start up the app.

Database migrations

Run database migrations with

npm run migrations:run

Add new DB migrations with

npm run typeorm:addmigration "your-migration-name"

Check TypeORM website for further info

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

API documentation

Register

POST /users

{
	"email": strin
	"name": string,
	"password": string
}

POST /auth/login

{
	"email": strin
	"password": string
}

Response includes generated JWT token

GET /users/profile

Add login (JWT) token to auth headers (token) Response includes profile information.

POST /messages

{
	"receiverId": int
	"message": string
}

Add login (JWT) token to auth headers (token). Send message to user identified by receiverId.

About

Example NestJS backend with some basic functionality

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published