This project was created as a training tool to demonstrate the basics of building a RESTful API using NestJS, TypeORM, SQLite3 and Jest. The main focus is to provide training on those technologies by performing CRUD operations (Create, Read, Update and Delete) on a User entity.
The User entity consists of 5 properties:
id: number // autogenerated
firstName: string
lastName: string
email: string
password: string
NestJS TypeORM SQLite3 Jest Fakerjs (for creating random test data)
This project provides the following API methods for managing the User entity:
GET /users
POST /users
GET /users/{id}
PUT /users/{id}
DELETE /users/{id}
With the application running, access http://localhost:3000/api for more details.
This project is meant to be used as a training tool to help developers understand the basic concepts of building a RESTful API using NestJS, TypeORM, SQLite3 and Jest. However, it should not be used as a base for a production project, as it does not include more advanced features such as password encryption, password rules validation, email validation, etc.
In src/users/users.service.spec.ts
you can find some unit tests that includes some examples of real case scenarios like:
- Mocking a repository
- Expecting a specific error to be thrown
- Testing asynchronous code
In test/app.e2e-spec.ts
there is only the "Hello World!" test generated by NesjJS, but that can be used as base to create API tests for the User API.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
This README file provides a general overview of the project and its purpose. Before using this project, please make sure you understand its limitations and that it is not intended to be used as a base for a production project.
If you have any questions or feedback, feel free to reach out!