- This will be updated as changes are made for the server.
- In the
postman
folder is where you will find the JSON for importing routes and data by example.
-
after cloning the repository: cd into the root directory (where the
index.ts
file andnode_modules
are located) the following command will remove the yarn lock file so that when installing the dependencies it will be a clean pull$ rm yarn.lock
and then:$npm i
oryarn
depending on the dependency manager you use. -
$ npm run start:watch
or$ yarn run start:watch
will start the serverCTRL-c
will stop the server -
$ npm test
or$ yarn test
to run test suite
note while running test suite ensure server is not running or an error will occur saying pot is already in use.
all routes are protected with JWT which can found here in the section titled verify signature
make sure that they match in the .env
file created if none is provided then the default secret is dev
for further security this can be swapped from a secret to a .pem
or private key.
All responses will be formatted listed below, however, should there be an error whether it is an authentication, policy or user format the object sent back will be:
{
"errors": ["<REASON_FOR_ERROR>"]
}
- "Authorization header missing" - this will be returned is no
Bearer
token is submitted in header - "Wrong authorization strategy" - this will be returned if the authorization strategy is not "Bearer"
- "Permission denied" - this will be returned if the user within the JWT doesn't have the appropriate role to access the route in question
- "No policies found" - this will be returned if the policy number or name for which is search is incorrectly applied or if there is no policy found.
- "No user found" - this will be returned
the reason for the array is because as the server grows there maybe different reasons and array of strings, or number for specific reasons, will be added.
localhost:3000/user/id/:id
-:id
represents the user id you are searching for. The return will be a JSON object of the user or if none is found a JSON object of the error format found aboutlocalhost:3000/user/name/:name
-:name
represents the user's name you are searching for. The return will be a JSON object of the client's name or an error format found aboutlocalhost:3000/policy/client-name/:name
-:name
represents the client's name for the policy you are searching for. The return will be a JSON array of policies attributed to the client's name or the error format found abovelocalhost:3000/policy/policy-number/:id
-:id
represents the policy number/id that you are searching for. The return will be a JSON object of the user according to the policy number or an error format found about