Giter VIP home page Giter VIP logo

nodejs-backend-structure's Introduction

NodeJS Project Structure

Recently I have started working on a new project and the issue that I faced was spending a lot of time building the project structure based on the best practices, especially with JavaScript/NodeJS that has a lot of approaches. I couldn't find any place that wraps the best practices into a single project, so I decided to make it on my own.

In this repository, I don't aim to provide any optimal solution as each project have its own necessity but to help anyone that is starting with a NodeJS project and can't find any inspiration on how to start building the project to take this project as the starting point.

Some of the good practices followed in this repository:

  • async & await support
  • WinstonJS logger implementation
  • Error Handling
  • Sequelize Support
  • Basic Joi Validation
  • Open API specification implemented through swagger-jsdocs and swagger-ui
  • JWT implementation
  • Enviroment variables to hold configuration values .env file
  • OOP (Object-Oriented Programming)
  • I followed airbnb coding standard with eslint, to help keep things into prespective.

How to start the project:

  • First, you clone the project by using the following command:
    git clone https://github.com/AlaaMezian/NodeJs-backend-structure.git
  • Install node version 8.11.0 or use nvm to downgrade your node version.
  • Delete the existing package.lock.json and run npm install
  • Then you create a postgres database named iLrn with the following credentials:
username: postgres
password: password
  • Run the migration using the following command: npx sequelize-cli db:migrate
  • Lastly, you run npm start

Future improvements utilize component based structure.
Please feel free to ⭐ and happy programming ✌️

nodejs-backend-structure's People

Contributors

alaamezian avatar dependabot[bot] avatar kylehue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-backend-structure's Issues

Error launching the project

I quite like the project folder structure, however its not able to run it after clone, it's missing some depencies.

Error: Cannot find module './termsAndConditionRouter'

It's nice using that just as template.

seperate validator schema from controller

Hi,
Your project structure is great, but i think if you seperate Schema's from controllers then your project structure will more cleaner.
A middleware function will validate req body data with the schema.

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.