Giter VIP home page Giter VIP logo

crud_nodees6_prisma's Introduction

Crud_nodeES6_Prisma

Petite API nodejs en Es6 avec Prisma et l'infrastructure Express

  • Os : Linux pop!_OS 21.04

Service utilsés :

  • Babel (Compilateur)
  • Jest avec Frisby (module de test)
  • Prisma (ORM)
  • Swagger (documentation automatique)

Installation :

1. Installer un service de base de données :

  • Ici j'ai utilisé un service SQL .

  • Voir la configuration du .env .

  • Si vous voulez d'autre services de bdd :https://www.prisma.io/docs/

2. .Env :

Aprés avoir pull ou téléchargé le projet, créez et configurez le .env à la base de celui-ci :

  • mariadb ou Mysql, initialisation identique.

De la forme :

mysql://USER:PASSWORD@HOST:PORT/DATABASE

Exemple : .env

DATABASE_URL="mysql://root:randompassword@localhost:3306/mydb"

Pour plus d'info voir la platform web : Prisma :

3. Installation des dépendances :

npm install

Les scrypts de démarrage :

"scripts": {
    "start": "npm run prod",
    "server": "node ./dist-server/bin/www",
    "watch:dev": "nodemon",
    
    "transpile": "babel ./server --out-dir dist-server",
    "build": "npm-run-all clean transpile",
    "clean": "rimraf dist-server",

    "dev": "NODE_ENV=development npm-run-all build server",
    "prod": "NODE_ENV=production npm-run-all build server",

    "test": "jest",
  
    "start-gendoc": "node ./dist-server/swagger.js"
  },
  • Pour démarrer le server avec la compilation automatique de babel et en mode "dev"
npm run watch:dev

Documentation :

  • Pour actualiser la documentation (actualisez pour tout changement dans la doc)
npm run start-gendoc
  • Route de la documentation : http://localhost:3000/doc

Pour plus d'informations sur la documentation Swagger et Swagger-autogen:

Test Jest :

  • Pour demarrer les tests Jest :
  • Les tests se font pendant que le server est actif ! (dupliquez les consoles)
npm run test

Pour plus d'informations sur Jest et Frisby :

Points de terminaisons implémentés :

/api/user

Chemin Méthode Description
/api/user/post POST Ajoute un user
/api/user/get POST Selectionne un user
/api/user/list GET Liste tout les users
/api/user/put PUT Mise à jour d'un user
/api/user/delete DELETE Supprime un user
  • Vous pouvez tester cette api avec la docummentaion : http://localhost:3000/doc
  • Avec Postman

Merci de votre intérêt

crud_nodees6_prisma's People

Contributors

dependabot[bot] avatar yo-an avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.