Skip to content

Instantly share code, notes, and snippets.

View nicolastakashi's full-sized avatar
🏠
Working from home

Nicolas Takashi nicolastakashi

🏠
Working from home
View GitHub Profile
@nicolastakashi
nicolastakashi / app.js
Created January 10, 2018 14:35 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection