🔥 This repo contains result of Node.js code assesment for recruitment process in Altran (today Capgemini Enginnering) 🔥 This plus really cool interview (and a job offer! 🥸) made me decide to join Capgemini. Today I create pimped versions of this little tool with AXA Insurance Central team from Barcelona.
.
First, clone this repo
git clone https://github.com/rafwit/dare-nodejs-assesment.git
Second, navigate to repo's root folder and run
npm install
To start application navigate to repo's root folder and run
npm start
Next, create .env file in the root folder containing following information
SERVER_PORT=3000
CLIENT_ID=<CLIENT ID THAT YOU PROVIDED TO ME>
CLIENT_SECRET=<CLIENT SECRET THAT YOU PROVIDED TO ME>
AUTHENTICATION_ENDPOINT=<INSURANCE API LOGIN ENDPOING>
CLIENTS_ENDPOINT=<INSURANCE API CLIENTS ENDPOING>
POLICIES_ENDPOINT=<INSURANCE API POLICIES ENDPOING>
SECRET_KEY=VerySecureSecretKey
- I have created REST API replicating all endpoints and their behaviour as explained in this swagger.
-
✅ Authentication: to be able to consume
GETendpoints user first need to login by sendingPOSTrequest to/login. As I was strictly instructed not to use DB I assumed dummy user authentication model:-
I extract
usernamefrom request, then my API consumesINSURANCE API,POSTto/loginand checks if the providedusernameexists.- if not:
400error is send back - if yes:
- save in in-memory cache
INSURANCE APItoken received fromINSURANCE API(user does not see it) - generate and send custom token for user (
USER TOKEN) - both
INSURANCE APIanduser tokenare stored for 560 seconds in cache, then deleted.
- save in in-memory cache
- if not:
-
user after login to be able to consume
GETendpoints needs to send authorization parameter withUSER TOKEN, if it will expire new session needs to be generated by user.
-
-
✅ Authorization: I verify the
roleof the user inINSURANCE API/clientsendpoint and assing roleuseroradmin
- I would develop cache 🧳 after consuming
INSURANCE APIclients and policies. I encountered issues with using etag and I would need more time to develop proper solution - I would add more tests 🧪