This NestJS API allows you to get informations about barcode through the Open Food Facts API. The main services are protected by an authentification mode (json web token).
- The firts step is to register an user (/register).
- Then you have to log in (/login) with this user. In return of this service you will obtain a token.
- Finally you can consume with this token the API's services and get informations about product thanks to its barcode (/products/).
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. All of the instructions are used with PowerShell (PSVersion 5.1.19041.610)
In order to run the container you'll need docker installed and started
You must have a MongoDB Cluster available
Clone the project
git clone https://github.com/sebastienbruno/crud-nestjs.gitcd crud-nestjs
Create a .env file with the properties below and change with your own values :
- DATABASE_URI=mongodb+srv://[username]:[password]@[url]/[database]?retryWrites=true&w=majority
- DATABASE_TEST_URI=mongodb+srv://[username]:[password]@[url]/[test_database]?retryWrites=true&w=majority
- JWT_SECRET='your_secret'
- JWT_EXPIRES_IN='10m'
And start the container.
docker-compose up dev- Once the application is running you can visit http://localhost:3000/api (or your env_url:env_port/api) to see the Swagger interface.
npm inpm run start- Once the application is running you can visit http://localhost:3000/api (or your env_url:env_port/api) to see the Swagger interface.
npm run testnpm run test:e2e
- NestJS - A progressive Node.js framework for building efficient, reliable and scalable server-side applications.
- Node - Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine
- Npm - Npm is a package manager
- Docker - Container solution
I use SemVer for versioning. For the versions available, see the tags on this repository.
- Sebastien BRUNO
- Add a logger system
- Add a validation pipe
- Add user update feature
- Add a caching system for Open Food Fact API
- Add a deployment manifest Kubernetes