A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/http-auth/http-auth-koa below:

http-auth/http-auth-koa: Koa framework integration with http-auth module.

Koa framework integration with http-auth module.

Via git (or downloaded tarball):

$ git clone git://github.com/http-auth/http-auth-koa.git

Via npm:

$ npm install http-auth-koa
// Authentication module.
const auth = require("http-auth");
const koaAuth = require("http-auth-koa");

const basic = auth.basic({
  realm: "Simon Area.",
  file: __dirname + "/../data/users.htpasswd"
});

// Koa setup.
const Koa = require("koa");
const app = new Koa();

// Setup basic handler.
app.use(async (ctx, next) => {
  await next();
  ctx.body = `Welcome to koa ${ctx.req.user}!`;
});

// Setup auth.
app.use(koaAuth(basic));

// Start server.
app.listen(1337, function() {
  // Log URL.
  console.log("Server running at http://127.0.0.1:1337/");
});

It uses mocha, so just run following command in package directory:

The MIT License (MIT)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4