Skip to content

mascam97/nestjs-api-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

96b0cfb ยท Jul 6, 2022

History

36 Commits
Jul 5, 2022
Jul 6, 2022
Jun 1, 2022
Jul 4, 2022
Jul 5, 2022
Jun 1, 2022
Jun 7, 2022
Jun 1, 2022
Jul 6, 2022
Jul 5, 2022
Jun 6, 2022
Jul 6, 2022
Jul 6, 2022
Jul 4, 2022
Jun 1, 2022
Jun 1, 2022

Repository files navigation

Nestjs API Store Stable Status Passing Coverage Docker build

Minimal store products

Project goal ๐Ÿฅ…

June 2022: Personal project to learn JavaScript as Backend with Nestjs and TypeScript.

Achievements June 2022 ๐ŸŒŸ

As Backend with PHP - Laravel I knew about APIs. So I developed the project by following some online courses, where I achieved:

  • Implemented Validations, Services, environment variables, documentation with Swagger and more
  • Configured NoSQL with MongoDB for the Database and Mongoose as a ODM
  • Implemented Authentication with Passport.js - JWT
  • Implemented Authorization with Guards
  • Added some e2e Testing for basic features

Then I made a Project definition to define the main business logic with a scope that allows scalability. Defining only the necessary resources to fit the Project goal.

TODOS

  • Improve testing e2e: Add fixtures to make some data, test for seller and administrator role
  • Add unit testing: There are some files made by default for some components, these does not work
  • Add Continuous Integration: Add some GitHub Actions for the testing
  • Add Docker container for the Nodejs project: The project is run in a local environment, it should in a container as database in a the same network
  • Improve business logic: There are some rules to define and fix, a review after making testing

Getting Started ๐Ÿš€

These instructions will get you a copy of the project up and running on your local machine.

Prerequisites ๐Ÿ“‹

The programs you need are:

Installing ๐Ÿ”ง

First duplicate the file .env.example as .env.

cp .env.example .env

Then install the JavaScript dependencies:

npm install

Create the images and run the services (MongoDB and MongoExpress):

docker compose up

Create a database called nestjs-store in Mongo Express from 8081 (http://localhost:8081/).

Finally, defines an API_KEY in .env file and run the server

# development
$ npm run start

# watch mode
$ npm run start:dev
NODE_ENV=stag npm run start:dev

# production mode
$ npm run start:prod
NODE_ENV=prod npm run start:dev

Testing

There are a special container for testing, the following commands are used to manage it

$ npm run db:test:up

$ npm run db:test:rm

$ npm run db:test:restart

Note: there are a .env.test file with the credentials for that testing database

Finally run the e2e testing with

$ npm run test:e2e

Built With ๐Ÿ› ๏ธ

Authors

Contributing

You're free to contribute to this project by submitting issues and/or pull requests.

References ๐Ÿ“š