Skip to content

Repository files navigation

CRUD NestJS

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/).

Table of contents

Getting Started

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)

Prerequisities

Docker.

In order to run the container you'll need docker installed and started

Database : You must have a MongoDB Cluster available

You must have a MongoDB Cluster available

Installation

Clone the project

  1. git clone https://github.com/sebastienbruno/crud-nestjs.git
  2. cd crud-nestjs

Configuration

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'

Usage with docker-compose

And start the container.

  1. docker-compose up dev
  2. Once the application is running you can visit http://localhost:3000/api (or your env_url:env_port/api) to see the Swagger interface.

Usage with npm

  1. npm i
  2. npm run start
  3. Once the application is running you can visit http://localhost:3000/api (or your env_url:env_port/api) to see the Swagger interface.

Running the tests

  • npm run test
  • npm run test:e2e

Built With

  • 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

Versioning

I use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Sebastien BRUNO

Next features

  • 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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages