Skip to content

Awesome express-restful template that includes JWT and social networks authentication (Google, Facebook, Twitter and Instagram)

License

Notifications You must be signed in to change notification settings

NachoJusticia/express-restful-api-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend RESTful API

This project is an express server template that is a good solution for production environments that need users' authentication.

Commitizen friendly JavaScript Style Guide: Good Parts contributions welcome

Features

Note that Facebook, Google and Twitter registration/login processes uses passport.

  • Authentication: JSON Web Token.
  • Data validation: all the database collections have their corresponding mongoose schema in a models module.
  • Good code styling: eslint and eslint-plugin-node are included.
  • Changelog: automatic features and bugfixes tracking in a changelog file.

Project structure

This server has a great folders structure. Tree command output tree -d:

.
├── src
│   ├── config
│   ├── routes
│   └── models
└── test
  • config: contains 3 JSONs to differenciate the different environments: dev (development), stg (staging) and pro (production).
  • routes: have all the routes splitted in different files by functionality (users, authentication, socialNetworksAuth, ...).
  • models: exports a factory containing all the models of the application.

Getting started

  • Clone repository
git clone https://github.com/NachoJusticia/express-restful-api-template
cd express-restful-api-template
  • Install dependencies
npm install
  • Set up the configuration requred
    • Social networks authentication: you will need to create a developer account in Facebook, Google and Twitter respectively.
    • Node-email-verification: it is required to add a valid email and password to use the SMTP service (Remember not to upload sensitive information to github).

Note that you have to provide all the required environment variables: BASE_URL, DB_URL, JWT_TOKEN, NEV_EMAIL, NEV_PASSWORD, NODE_ENV, PORT.

  • Server launching options:
  1. In a production and staging environment.
npm run start
  1. Development environment: restart server when modifying any file and save.
npm run start-dev
  1. Development environment: debuggin. After using the following command attach to the proces in the port 9229 for being able to inspect the code.
npm run start--dev-debug

Author

Ignacio Justicia Ramos: ignaciojusticia@gmail.com

Contributing

Contributions are welcome, please fork this repository and send Pull Requests! If you have any ideas on how to make this project better then please submit an issue.

About

Awesome express-restful template that includes JWT and social networks authentication (Google, Facebook, Twitter and Instagram)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published