-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3290f6e
Showing
6 changed files
with
531 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# NodeJs and Express Tutorial | ||
|
||
## Description | ||
|
||
This repository is a reference for a turotial I wrote on creating a basic JSON server using Express and NodeJS. | ||
|
||
## Setup | ||
|
||
1. Download or clone this repo: | ||
git clone https://github.com/grobergm/node-express-tutorial | ||
2. Install Depandancies: npm install | ||
3. Navigate to the root directory | ||
4. Start the server file: node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const checkToken=function(req,res,next){ | ||
let token=req.headers['authorization'] | ||
|
||
if (token){ | ||
// In practice use json web token verify method to check if token is valid | ||
// when next is called in middleware, it will run the next function | ||
next() | ||
} else { | ||
res.json({ | ||
success:false, | ||
message:'no token in headers' | ||
}) | ||
} | ||
} | ||
|
||
module.exports= { | ||
checkToken:checkToken | ||
} |
Oops, something went wrong.