mirror of https://github.com/msgbyte/tailchat
chore: add oidc page test server
parent
23b1a851a9
commit
2dfe88b5dd
@ -0,0 +1,67 @@
|
|||||||
|
import express from 'express';
|
||||||
|
import path from 'path';
|
||||||
|
import ejs from 'ejs';
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const port = process.env.PORT || 8080;
|
||||||
|
|
||||||
|
const publicDir = path.resolve(__dirname, '../../../public');
|
||||||
|
const viewRootDir = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
'../../../services/openapi/oidc/views'
|
||||||
|
);
|
||||||
|
|
||||||
|
app.use(express.static(publicDir));
|
||||||
|
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
res.send(
|
||||||
|
`<ul>${['/login', '/authorize', '/error']
|
||||||
|
.map((p) => `<li><a href=${p}>${p}</a></li>`)
|
||||||
|
.join('\n')}</ul>`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/login', async (req, res) => {
|
||||||
|
const data = {
|
||||||
|
uid: 'fooooooooo',
|
||||||
|
};
|
||||||
|
const html = await ejs.renderFile(
|
||||||
|
path.resolve(viewRootDir, './login.ejs'),
|
||||||
|
data
|
||||||
|
);
|
||||||
|
|
||||||
|
res.send(html);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/error', async (req, res) => {
|
||||||
|
const data = {
|
||||||
|
text: 'fooooooooo',
|
||||||
|
};
|
||||||
|
const html = await ejs.renderFile(
|
||||||
|
path.resolve(viewRootDir, './error.ejs'),
|
||||||
|
data
|
||||||
|
);
|
||||||
|
|
||||||
|
res.send(html);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/authorize', async (req, res) => {
|
||||||
|
const data = {
|
||||||
|
logoUri: 'loginUrl',
|
||||||
|
clientName: 'Test',
|
||||||
|
uid: 'foooo',
|
||||||
|
details: {},
|
||||||
|
params: {},
|
||||||
|
session: '',
|
||||||
|
};
|
||||||
|
const html = await ejs.renderFile(
|
||||||
|
path.resolve(viewRootDir, './authorize.ejs'),
|
||||||
|
data
|
||||||
|
);
|
||||||
|
|
||||||
|
res.send(html);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`Server: http://127.0.0.1:${port}`);
|
||||||
|
});
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "openapi-oidc-page",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"private": true,
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "ts-node ./index.ts",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.17.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/express": "^4.17.15",
|
||||||
|
"ts-node": "10.9.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue