Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
grobergm committed Aug 1, 2019
0 parents commit 3290f6e
Show file tree
Hide file tree
Showing 6 changed files with 531 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
13 changes: 13 additions & 0 deletions README.md
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
18 changes: 18 additions & 0 deletions middleware.js
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
}
Loading

0 comments on commit 3290f6e

Please sign in to comment.