A Node.js app for basic authentication using MongoDB.
Prerequisites: Node.js. MongoDB.
git clone https://github.com/nickpersad/nodejs-mongodb-auth.git
cd nodejs-mongodb-auth
npm install
#Copy default environment file and add your config variables
cp .env.default .env
#Run in dev environment with hot reload or run with built app
npm run start:dev
Your app should now be running on localhost:8080.
All requests must be POST requests, GET requests are forbidden.
Only allows unique users, if a user exist, the user will be rejected. Passwords are hashed using [bcrypt] (https://en.wikipedia.org/wiki/Bcrypt). Sample request
{
"username": "[email protected]",
"password": "qwerty123456"
}
Sample response
{
"success": true,
"id": "5eb1a808b6228ew2b582ds19"
}
Sample request
{
"username": "[email protected]",
"password": "qwerty123456"
}
Sample response
{
"success": true,
"id": "5eb1a808b6228ew2b582ds19"
}
Sample request
{}
Sample response
{
"success": true,
"results": [
{
"id": "22966r34df38a67003e55c11",
"username": "[email protected]"
},
{
"id": "5496921c990295718393a896",
"username": "[email protected]"
}
]
}
Sample request
{
"username": "[email protected]"
}
Sample response
{
"success": true
}
########################################################################
## Environment variables used for Node App
##
## DEBUG - 1 is ON: errors/info will be shown in console. 0 is OFF: errors/info will be shown in GrayLog.
## PORT - Port to set Node to listen on.
## APPLICATION_NAME - Name of application.
## MONGODB_CONNECTION - Connection to MongoDB.
## EMAIL_HOST - Email hostname
## EMAIL_PORT - Email port
## EMAIL_USER - Email address/username
## EMAIL_PASS - Email password
##
########################################################################