Skip to content

πŸš€ A starter for building production-ready RESTful APIs using Node.js, Express, Mongoose, and more.

License

Notifications You must be signed in to change notification settings

vinodnimbalkar/express-api-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

87 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Express-API-Starter

Initially I was using express-generator (still using), but ended-up doing same thing again and again 'user JWT authentication with refresh token and suscription plan' so i decided to create git repository.

Features

  • Stateless authentication with JWT allowing for easy horizontal scaling (expiriIn: 2 Minute)
  • ESLint Maintain your code quality with ease (Airbnb JavaScript Style).
  • MongoDB database
  • RefreshToken It can be used to acquire new access Tokens. (expireIn: 7 days)
  • Subscription New user initially as 'Trial' and after 7 days as 'Free'.
  • Email sendgrid to send welcome and cancellation email.
  • Device Limit Only two device login limit.

Dependencies

  • express (server)
  • body-parser (reading body data)
  • validator (input validation)
  • helmet (Helmet helps you secure your Express apps by setting various HTTP headers.)
  • cors (enable CORS)
  • mongoose (Mongoose is a MongoDB object modeling tool)
  • morgan (HTTP request logger middleware for node.js)
  • express-rate-limit (ratelimiting endpoints)
  • bcryptjs (password Encryption)
  • jsonwebtoken (jwt creation & signing)
  • compression (compress response bodies)
  • dotenv (It loads environment variables from a .env file into process.env)
  • multer (handling multipart/form-data)
  • sharp (convert large images in common formats to smaller)
  • debug (A tiny JavaScript debugging utility)
  • sendgrid (just want to send email)

Dev Dependencies

  • nodemon (hot-reload)
  • eslint (ESLint is a linter for the JavaScript programming language.)
  • eslint-config-airbnb-base (Airbnb JavaScript Style)
  • jest (Jest is a delightful JavaScript Testing Framework with a focus on simplicity.)
  • supertest (HTTP assertions made easy via superagent.)

Installation

  1. Clone the project git clone https://github.com/vinodnimbalkar/express-api-starter.git.
  2. cd express-api-starter
  3. Make it your own rm -rf .git && git init && npm init
  4. Install dependencies npm install
  5. Create a .env file in the root like the .env.example file.
  6. For dev you need to have mongodb db locally.
  7. For dev - npm run dev
  8. For lint - npm run lint
  9. For test - npm run test

Stucture

β”œβ”€β”€ app.js
β”œβ”€β”€ bin
β”‚Β Β  └── www
β”œβ”€β”€ .env
β”œβ”€β”€ .eslintrc.js
β”œβ”€β”€ .gitignore
β”œβ”€β”€ jest.config.js
β”œβ”€β”€ LICENSE
β”œβ”€β”€ nodemon.json
β”œβ”€β”€ package.json
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ public
β”‚Β Β  β”œβ”€β”€ images
β”‚Β Β  β”œβ”€β”€ index.html
β”‚Β Β  β”œβ”€β”€ javascripts
β”‚Β Β  └── stylesheets
β”‚Β Β      └── style.css
β”œβ”€β”€ README.md
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ controllers
β”‚Β Β  β”‚Β Β  └── user.js
β”‚Β Β  β”œβ”€β”€ db
β”‚Β Β  β”‚Β Β  └── mongoose.js
β”‚Β Β  β”œβ”€β”€ email
β”‚Β Β  β”‚Β Β  └── account.js
β”‚Β Β  β”œβ”€β”€ middleware
β”‚Β Β  β”‚Β Β  └── auth.js
β”‚Β Β  β”œβ”€β”€ models
β”‚Β Β  β”‚Β Β  └── user.js
β”‚Β Β  └── routes
β”‚Β Β      β”œβ”€β”€ index.js
β”‚Β Β      └── users.js
└── tests
    └── user.test.js

13 directories, 21 files

TODO

  • signup email verification by sending OTP
  • Add docker support

Contributing

Feel free to open an issue (or even better, send a Pull Request). Contributions are very welcome!! πŸ˜„

License

MIT Β© Vinod Nimbalkar

About

πŸš€ A starter for building production-ready RESTful APIs using Node.js, Express, Mongoose, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages