Skip to content

Instantly share code, notes, and snippets.

View ArthurMbraga's full-sized avatar

Arthur Martins ArthurMbraga

View GitHub Profile
@ArthurMbraga
ArthurMbraga / README-Template.md
Created September 5, 2021 22:13 — forked from DomPizzie/README-Template.md
A simple README.md template

Project Title

Simple overview of use/purpose.

Description

An in-depth paragraph about your project and overview of use.

Getting Started

@ArthurMbraga
ArthurMbraga / authentication.js
Last active November 13, 2020 01:01
Token JWT authentication middleware for NodeJs
const jwt = require('jsonwebtoken');
module.exports = {
async authenticateToken(request, response, next) {
const authHeader = request.headers['authorization']
const [scheme, token] = authHeader && authHeader.split(' ');
if (token === null) return response.status(401).json({ error: 'No token provided' });
if (!/^Bearer$/i.test(scheme))