This project is a REST API for a blog that manages users, posts and authentication.
- Node.js
- NestJS
- MongoDB
- Mongoose
- Typescript
- Swagger
- Passport JWT
- Passport Local
- Bcrypt
- Docker
- Testcontainers (for e2e tests, used for starting a mongoDB container)
- Make sure you have installed Node.js version 20.10.0 and MongoDB
- Make sure you have a .env file with the environment variables
- Make sure MongoDb is running
- The application will be available at http://localhost:3000
- You can access the Swagger documentation at http://localhost:3000/api
- The .env file should be placed at root folder and contain the following environment variables:
MONGO_URL=mongodb://localhost:27017/blog
JWT_SECRET=S3Cr3t
EXPIRES_IN=24h
BCRYPT_SALT_ROUNDS=10
- Make sure you have installed the NestJS CLI if you are going to run the application in dev mode
npm i -g @nestjs/cli
# install dependencies
npm install
# development
npm run start
# watch mode
npm run start:dev
# production mode
npm run start:prod
-
It is necessary to have Docker installed and running
-
Docker will create a container with the application and another with the MongoDB database
-
The application will be available at http://localhost:3000
-
You can access the Swagger documentation at http://localhost:3000/api
-
The .env file should be placed at root folder and contain the following environment variables:
MONGO_URL=mongodb://mongo:27017/blog
JWT_SECRET=S3Cr3t
EXPIRES_IN=24h
BCRYPT_SALT_ROUNDS=10
docker compose up --build
- e2e tests are written using Jest, Supertest and Testcontainers (It requires Docker installed and running)
npm run test:e2e