NOTICE: 2021/04/09 servestjs.org no longer hosts typescript files. Use https://deno.land/x/servest

Basic Auth

Servest provides Basic Aauth (RFC7617) middleware by official. Add basicAuth()middleware into your router or routes.

import { basicAuth, createApp } from "https://deno.land/x/[email protected]/mod.ts";
const app = createApp();
// Add global auth middleware
app.use(
  basicAuth({
    credentials: [{
      username: "deno",
      password: "deno is nice",
    }, {
      username: "node",
      password: "node is awesome",
    }],
  }),
);
app.get("/", async (req) => {
  await req.respond({
    status: 200,
    headers: new Headers({
      "content-type": "text/plain",
    }),
    body: "Hello, Servest!",
  });
});
app.listen({ port: 8899 });