diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a138d15 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible Node.js debug attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceRoot}\\bin\\www" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 084f408..7ba852b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,43 @@ # Node Server Auth API ``` -> git clone -> cd +> git clone https://github.com/jwill9999/Node_Auth_API_with_JWT_Boilerplate.git +> cd Node_Auth_API_with_JWT_Boilerplate > npm install > npm run dev > This will open automatically on http://localhost:3000 ``` -## Instructions +## Key Features + +> Node Express Server + +> API Backend + +> MongoDb Database + +> Authorisation + +> Passport Js Local and JWT + +> Json Web Tokens + +> AuthGuards + +> Bcrypt Salt and Hash Encryption + + +## Links + +[Expressjs](https://expressjs.com/) + +[passportjs Local](http://passportjs.org/docs/username-password) + +[Passportjs JWT](https://github.com/themikenicholson/passport-jwt) + +[MongoDb Docs](https://docs.mongodb.com/manual/) + +[Bcrypt for nodejs](https://github.com/shaneGirish/bcrypt-nodejs) + -UNDER CONSTRUCTION :) \ No newline at end of file diff --git a/app.js b/app.js index b84f770..72d683e 100644 --- a/app.js +++ b/app.js @@ -4,6 +4,7 @@ const favicon = require('serve-favicon'); const logger = require('morgan'); const cookieParser = require('cookie-parser'); const bodyParser = require('body-parser'); +const Now = require('./mymiddleware'); const index = require('./routes/index'); const users = require('./routes/users'); @@ -27,6 +28,7 @@ app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); +app.use(Now); app.use('/', index); app.use('/users', users); diff --git a/mymiddleware.js b/mymiddleware.js new file mode 100644 index 0000000..01f163a --- /dev/null +++ b/mymiddleware.js @@ -0,0 +1,11 @@ + + +module.exports = function date(req, res, next) { + + if (req.url === '/') { + let date = new Date(); + date = date.toUTCString(); + console.log(`${req.method} ${req.url} was accessed at ${date}`); + } + next(); +} \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index 35ec93b..41969d6 100644 --- a/routes/index.js +++ b/routes/index.js @@ -10,7 +10,7 @@ const AuthGuard = passport.authenticate('jwt', { session: false }); const local_Login = passport.authenticate('local', { session: false }); /* GET '/' */ -router.get('/', AuthGuard, function (req, res, next) { +router.get('/', function (req, res, next) { res.send('Working ok '); });