Skip to content

Instantly share code, notes, and snippets.

View IftekharDani's full-sized avatar

Iftekhar Dani IftekharDani

  • Ahmedabad.
View GitHub Profile
@IftekharDani
IftekharDani / app.js
Created April 10, 2018 07:25 — 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