This is a simple NilaAuth code snippet for setting up authentication using Express.js. It utilizes MongoDB for database storage and JSON Web Tokens (JWT) for authentication.
- Node.js installed on your machine
- MongoDB installed and running locally
- Basic nodejs project
git clone https://github.com/gotocva/nila-auth
- In your project, import
express
and the authentication middleware functionauth
fromnila-auth
:
const express = require('express');
const { auth } = require('nila-auth');
const app = express();
const authOptions = {
name: 'siva',
MONGODB_URL: process.env.MONGODB_URL,
JWT_SECRET: process.env.JWT_SECRET
}
auth(app, authOptions);
app.listen(3000, () => {
console.log('Application running on port 3000');
});
TODO : Once the auth connected to your project by default it has some api's will update the API documentation soon.
This code is provided under the MIT License. Feel free to use it and modify it as needed.
This NilaAuth was created by Siva Bharathy.
Special thanks to the developers and contributors of Express.js and MongoDB for their amazing work.