A Simple Token-Based User Authentication Service using JWT in Node JS and MongoDB.
With this you can quickly craft a token-based user authentication system using JWT and continue your project implementation. This comes with User Registration
, Email Verification
, Login
, Password Reset
, Account Deletion
, Logout
.
Clone or download this repository to your machine:
- Clone the repo:
git clone https://github.com/bytesfield/node-auth-service.git
- Download from Github.
npm install
to install all application dependencies.
Update Environment variables, rename .env.example
to .env
and secrets.json.example
in config
folder to secrets.json
then update MDB_DATABASE_CONNECT
value to your MongoDB database connection and update APP_PORT
to your desired port default is 3000
, also APP_ENV
to production
or test
depending on your environment default is test
.
For email configuration on .env
or secrets.json
files, update the EMAIL
or MAILGUN
credentials respectively depending on your mailing service. When using mailgun, export the mailgunService
from the nodemailer.js
in the config
folder, while emailService
if you are using a normal mailing service and pass the required parameters for sending mail.
Lastly update JWT_SECRET
and COOKIE_SESSION_SECRET
to your desired values.
Start your development server : npm start
this serves the application to default localhost:3000
Open Postman run the Api endpoints. Documentation can be accessed below
Note: Use active emails for testing as you will receive emails to your inbox.
The API documentation is hosted on Postman Doc
Want to suggest some improvement on the codes? Make a pull request to the dev
branch and it will be reviewed and possibly merged.
Find me on
Twitter.
Linkedin.
Source codes is license under the MIT license.