/node-multi-authorizer-jwt

Multiple Authorizers in NodeJs JWT

Primary LanguageJavaScript

Multiple Authorizer in Nodejs JWT

This is for coding test.
Multiple Authorization in Nodejs JWT

NodeJs NPM Express Language Star Count

Table of Contents

  • File Structure
  • npm Dependences
  • How to Install
  • How to Run
  • How to Test
  • Swagger
  • Acknowledgement

File Structure

Structure is base on lambda functions.
So we can easily deploy to lambda or ECS or EC2 as the monolith or microservice.
We can separate authorizer and functions too.
All the services on our code would be functions in Lambda and middleware will be lambda Authorizer as well as all the others are the layers.

.
├── data                        # dir for sqlite3 database
|   └── codetest.sqlite3        # sqlite3 db file
├── resources                   # for documentations resources
│   └── ...
├── sc                          # nodejs source code
│   ├── authorizers             # administrator and customer middlewares
│   │   └── ...                 
│   ├── common                  # for the common functions
│   │   └── ...
│   ├── lib                     # just for system configuration files
│   │   └── ...
│   ├── models                  # tables
│   │   └── ...
│   ├── routes                  # urls and prefixs
│   │   └── ...
│   └── services                # Controllers , we can deploy them to AWS Lambda functions
│       ├── admin               # For all admin functions
│       │   └── ...
│       └── user                # For all user functions
│           └── ...
├── tests                       # api test
│   └── ...
├── README.md              
└── ...

npm Dependences

How to install

We have to install npm dependence to run our program smoothly. pls follow as the singlie line of the following command.

npm install

alt text

How to Run

Configuration is just for dev(local) only. we can easily execute our program in local as the following command.

npm run dev

How to Test

I use jest and supertest npm package for testing. main program is base on commajs and jest is base on model type. however we can run and test our program because i have configured in package.json. You can check the testing source code in ./test directory too. Here is the command to run the testing.

npm test

alt text

Swagger

we can reach to our swagger from this link...
Link API Doc swagger -> http://localhost:9999/swagger/ We can test the api ourselves.

alt text

Acknowledgement

Thank you all for giving me a chance to answer the coding test.
I'm looking forward to work with you and I could make a promise that " I would do my best ".