An Express/Node.js based server using a custom “authentication” module that is designed to handle user registration and sign in using Basic, Bearer, or OAuth along with a custom “authorization” module that will grant/deny users access to the server based on their role or permissions level. It can dynamically perform CRUD operations to a MongoDB database and power multiple different frontend applications, using the REST standard.
- CI/CD (GitHub Actions)
- Back-End Server URL
The application will be created with the following overall architecture and methodologies
-
Node.js
-
ES6 Classes and best practices
-
ExpressJS Web Server, built modularly
- Middleware for handling 404 and 500 conditions
- Middleware for handling the dynamic loading of the correct data model as specified in the route
- Inspect the route, looking for the model name
- require() the correct module model (i.e. if the model is categories, require('src/models/categories/categories-model.js'))
- Use a single router (v1.js) to handle the ReST methods for CRUD for any model
- express.params middleware
-
Persistence using a Mongo Database (NoSQL)
-
Mongoose Schemas (data models) to define and model data
-
Mongoose Model “wrapper” class to serve as the API between the express server and the data models themselves
-
Test Driven Development, using Jest
- Tests will be runnable locally
- Tests will auto-execute (CI) in your repo using GitHub actions
- Tests will use a 3rd party library called supergoose to:
- “mock” the mongo running database
- “mock” the running Express server
-
Deployment to Heroku
- Make sure MongoDB is installed locally
- Clone down this repo
- Install Dependencies:
npm install
- Create an .env file and add the following:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/authenticated-api-server
SECRET= << Pick a secret word. This is to authenticate a token with your front end application>
CLIENT_ID= get this from github
CLIENT_SECRET= get this from github
STATE= pick anything you want
TOKEN_SERVER=https://github.com/login/oauth/access_token
REDIRECT_URI=http://localhost:3000/oauth
REMOTE_API=https://api.github.com/user
- Run
nodemon index.js
The following routes are available:
/signup
/signin
api/v1/categories
api/v1/products
api/v1/todo
api/v2/categories
api/v2/products
api/v2/todo
- In the terminal enter:
npm test