Skip to content

Commit

Permalink
Completed code with additions to Readme file including links and refe…
Browse files Browse the repository at this point in the history
…rences
  • Loading branch information
Jason Williams committed Jun 2, 2017
1 parent d6b301f commit bab1893
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 :)
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions mymiddleware.js
Original file line number Diff line number Diff line change
@@ -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();
}
2 changes: 1 addition & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ');
});

Expand Down

0 comments on commit bab1893

Please sign in to comment.