Skip to content

Simple User API implemented using NestJS, Typescript, TypeORM and SQLite3 for training purposes.

License

Notifications You must be signed in to change notification settings

renatosugimoto/ts-nestjs-trainning

Repository files navigation

User API Project in NestJS

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.

User Entity

The User entity consists of 5 properties:

id: number // autogenerated
firstName: string
lastName: string
email: string
password: string

Technologies Used

NestJS TypeORM SQLite3 Jest Fakerjs (for creating random test data)

Available API Methods

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.

Project Purpose

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.

Test examples

Unit tests

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

API/e2e tests

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.

Installation

$ npm install

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

README file

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!

About

Simple User API implemented using NestJS, Typescript, TypeORM and SQLite3 for training purposes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published