mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
23 lines
519 B
TypeScript
23 lines
519 B
TypeScript
|
import express from 'express';
|
||
|
import basicAuth from 'express-basic-auth';
|
||
|
|
||
|
import { basicAuthCreds } from '../fixtures/constants';
|
||
|
|
||
|
const { utf8, latin1 } = basicAuthCreds;
|
||
|
|
||
|
const users = {
|
||
|
[utf8.encoded.user]: utf8.encoded.pass,
|
||
|
[latin1.encoded.user]: latin1.encoded.pass,
|
||
|
};
|
||
|
|
||
|
export const basicAuthRouter = express.Router();
|
||
|
|
||
|
basicAuthRouter.use(basicAuth({ users }));
|
||
|
|
||
|
basicAuthRouter.get('/', (_, res) => {
|
||
|
res
|
||
|
.status(200)
|
||
|
.header('content-type', 'text/plain')
|
||
|
.send('basic auth received');
|
||
|
});
|