The project consists of an online platform for buying and selling books and stationery. Written with Typescript the backend provides the necessary data for the application frontend.
First you must to clone the repository using:
$ git clone 'https://github.com/paperbook-official/api.nestjs.paperbook.git'
After that install all the needed dependencies with:
$ npm install -g @nestjs/cli
$ npm install
This project uses husky's commit-msg hook and commitlint. For using them run the following commands:
$ npx husky install
$ npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'
# development
$ nest start
# watch mode
$ nest start --watch
# production mode
$ nest start --prod
The application uses Docker and it can be runned using the follwing:
$ sudo docker-compose -up
To test this application, SQlite database can be used, it is added in dependencies by default. To use simply run any of the application startup commands shown above.
obs: You must not forget of setting up the .env file
The PostgreSQL is used for production environments.
For creating a new migration run the command:
$ npm run typeorm:migrate MIGRATION_NAME
And for executing all the migrations run:
$ npm run typeorm:run
Always, when creating a new entity, create a folder in 'src/modules' with the entity name (Ex: 'src/modules/product' ). Inside the folder, it must have the following structure:
product
controllers
(All the controllers related with products)product.controller.ts
services
(All the services related with products)service.controller.ts
entities
(All the entities related with products)product.entity.ts
models
(All the models related with products)create-product.dto.ts
product.dto.ts
update-product.dto.ts
product.module.ts
This project has only one authentication method, the local. Basically login to the application can be done using the user's email and password.
The backend is integrated with Swagger API, allowing the developer to view and test the API routes.
To use this put in browser url the following:
API_ENDPOINT/swagger
The application is also integrated with Sentry this way it allows tracking exceptions and storing them.
Paperbook API is MIT licensed.