Skip to content
/ node-api-starter Public template

Full-featured starter for Node Rest API server using ExpressJS

License

Notifications You must be signed in to change notification settings

Kamahl19/node-api-starter

Repository files navigation

Node API Starter

What’s Inside?

  • Express.js - fast, unopinionated, minimalist web framework for Node.js
  • JWT Authorization - including all the common features such as Sign-up, Login, Logout, Forgotten password, Email verification
    • bcrypt.js - bcrypt in plain JS with zero dependencies
  • Mongoose - MongoDB ORM
    • DB Seeding
    • DB Migrations
  • Nodemailer - email service
  • Joi - object schema data validation library
    • Celebrate - joi validation middleware for Express
  • Pino - full-featured logging service
  • es6-error - easily-extendable error for use with ES6 classes
  • http-status - utility to interact with HTTP status code in Node.js
  • ESLint - pluggable linting utility
  • Prettier - opinionated code formatter
  • Husky & lint-staged - run ESLint & Prettier before commiting new code
  • Dotenv - loads environment variables from an .env file
  • Nodemon - monitors for any changes and automatically restarts the server

Getting Started

This project uses dotenv for setting environmental variables during development. Simply copy the .env.example file, rename it to .env and add your env variables as you see fit. There is also a src/config.js file with several configuration options.

Install, Seed DB & Start the server

npm install
npm run seed
npm start

The server will start at https://localhost:3001

Deployment to Heroku

heroku login
heroku create my-app
git init
heroku git:remote -a my-app
git add .
git commit -am "initial commit"
git push heroku master

Project structure

-| src/
 |--| app/: Main application (framework) files.
 |--| common/: Reusable common files such as messages, validation rules, services, utils etc.
 |--| features/: Features bundled into separate modules
 |--| seeds/: DB seed files
 |--| config.js: Global application config file
 |--| index.js: Application entry file

Prettier

This project uses Prettier, an opinionated code formatter. In order to format code manually, run npm run format in app root directory. All the code is also formatted automatically on pre-commit hook. There is also npm run format-check for CI purposes to check if code is formatted properly.

ESLint

Project comes with ESLint configured. It helps you prevent common errors.

There are multiple ways how to run ESLint.

  • CLI: npm run lint
  • it runs automatically on pre-commit hook
  • in IDE if supported (Visual Studio Code supports reports)

Updating dependencies

Project comes with the default Renovate config renovate.json. It takes care of automated dependency updates and it's free for open-source projects. More about how to configure here.

About

Full-featured starter for Node Rest API server using ExpressJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •