Giter VIP home page Giter VIP logo

assetsapi's Introduction

Compte rendu de l'événement Google Developers Group (DEVFEST 2022) El Jadida 17-12-2022 :

https://docs.google.com/presentation/d/1bkmuSkElq_7pLptG7KC_qn3817yDXrjGScwJo7inKmI/edit?usp=sharing

Create a prject MERN Stack :

  • backend : Nodejs, Expressjs, MongoDB , Mongoose, Bcryptjs, Jsonwebtoken, Cors

  • frontend : Reactjs, ReduxToolkit, Bootstrap, React-toastify

    README-Template

GOALDAY

Table of Contents

Table of Contents
  1. certifications
  2. commandeline
  3. built

Introduction

Create a maintainable and scalable Node.js REST API with Express and Mongoose.

The structure of the project is based on MVC and follows its basic principles but is a little different in that instead of having the logic of entities distributed in specific folders (models folder containing all models, controllers folder containing all controllers etc...).

Each entity has it's own folder containing all it's core logic . Let's take the User entity as an example:

backend
└── entities
    └── controllers
        ├── userController.js
    └── models
        ├── userModel.js 
    └── routes
         └── userRouter.js

Thanks to this structure, it is easier to maintain and evolve multiple entities (you will rarely have to switch from one folder to another to manage an entity).

The project comes with many built-in features, such as:

  • Authentication with JWT: providing both an access token and a refresh token (sent as a secure http cookie only and stored in the database).
  • Unified login system to support multiple user roles.
  • Validation using nodemailer.
  • Error handling and custom error capture method.
  • Optional population, selection of fields to fill and fields to return by GET requests.

Translated with www.DeepL.com/Translator (free version)

  • Plus de détails ci-dessous...

Certifications

Built With

This section should list all the major frameworks/libraries used to launch your project. Leave the add-ons/plugins for the acknowledgements section. Here are some examples.

  • [![express][express.js]][express-url]

Commande line

npm init

Setup

Usage

*By default, it uses npm to install dependencies.

  • If you prefer another package manager you can pass it as an argument yarn

Then open the project folder and install the required dependencies:

npm init
npm install express

Back to table of Contents

Configuration

Setup your environment variables. In your root directory, you will find a .env:

 .env

Then:

npm  start

The database must be connected and your server must be running. You can start testing and querying the API.

npm run start

Back to top

Directory Structure

backend/
├──controllers/                 # Contains mostly global and reusable logic (such as auth and crud)
├── db/                         # Database, routes and server configurations
├── middlewares/                # Express middlewares
├── routes                      # Contains entity templates (default and user type)
├── models/                     # Custom/global type definitions
└── index.ts                    # App entry point (initializes database connection and express server)

Back to table of Contents

Features

API Endpoints

List of available routes:

Auth routes (public):
POST /api/ - register
POST /api/login - login
GET /api/me - getMe\

User routes (private):
GET /api/users - get all users
GET /api/users/:id - get user by id
PATCH /api/users/:id - update user
DELETE /api/users/:id - delete user

Back to table of Contents

📜 Credits

ZOUHAIR BEGDAR

GitHub Badge LinkedIn Badge

assetsapi's People

Contributors

begdar8zouhair avatar

Stargazers

 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.