{"repo":"codetit4n/node-jwt-auth-template-ts","free":true,"listed":false,"github":"https://github.com/codetit4n/node-jwt-auth-template-ts","clone":"git clone https://github.com/codetit4n/node-jwt-auth-template-ts.git","description":"Basic template you can use in your Node Backends for JWT authentication - TypeScript edition. Uses Node.js, Express.js and MongoDB.","language":"TypeScript","stars":12,"topics":["express","node","ready-to-use","mongodb","authentication","backend-api","hashedpassword","jwt-authentication","jwt-bearer-tokens","protected-routes"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"JWT authentication template for Node Backend - TypeScript edition Basic template you can use in your projects for JWT authentication. It is built using Node.js, Express.js and MongoDB. It has amazing Type Security which is possible because of TypeScript. Routes: /api/user/register - POST Creates a new user. It takes name, email and password in the request body and stores the name, email and hashed password in the Mongo database. /api/user/login - POST Logs in the registered user and sends a new signed JWT. This JWT can be stored in local storage, etc. /api/protected - GET Simple protected route, just for testing the JWT. You will need a valid JWT to access this route. Put the JWT in the header like: Authorization: 'Bearer [JWT]' How to use this template: 1. Clone the repo using: 2. Rename .env.example to .env 3. Update the .env file with project secrets like: - JWT SECRET: Encryption key to sign your JWTs. You can get one from: https://www.allkeysgenerator.com - JWT LIFETIME: How much time a particular JWT will be valid for. Example: 30d - for 30 days. - MONGO URI: Sign up for a free mongoDB account, if you don't have any. Create a new cluster and connect it using this URI. Refer: https://www.mongodb.com/docs/manual/reference/connection-string - PORT: This is optional. By default the port will be 3000. 4. Go inside the project and run the following commands: 5. Edit the src/routes/protected.ts file for the protected routes according to your project's needs. One example is pro","default_branch":null,"files":null,"tree":[],"storefront":"/r/codetit4n","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/codetit4n/node-jwt-auth-template-ts/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}