Company: Unicult_8oct
Difficulty: medium
Problem Description Build a REST API in Node.js that handles user authentication with JSON Web Tokens (JWT). The service relies on the Sequelize ORM to read and write a User database model. You need to implement the endpoints that mint a fresh JWT after a successful login, save that token in the database, and later verify tokens that are presented back to the service. Endpoints POST /login : Authenticates a user, generates a JWT, updates the database with the token, and returns the token. POST /validate : Decodes and verifies a provided JWT and returns the associated username. Request Format POST /login Expects a JSON body containing the user's credentials: { "username": "Jarvisporter", "password": "myfewsord" } POST /validate Expects a JSON body containing the JWT to validate: { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } Response Format POST /login Success (200 OK): Returns the newly generated JWT: { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } POST /validate Success