This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -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}`);
});

View File

@@ -0,0 +1,22 @@
{
"name": "openapi-oidc-page",
"version": "1.0.0",
"description": "",
"private": true,
"main": "index.js",
"scripts": {
"start": "ts-node ./index.ts",
"dev": "nodemon --watch \"index.ts\" --watch \"../../../services/openapi/oidc/views/**\" --ext \"ts,ejs\" --exec \"ts-node --transpile-only ./index.ts\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"express": "^4.17.2"
},
"devDependencies": {
"@types/express": "^4.17.15",
"nodemon": "^3.0.1",
"ts-node": "10.9.1"
}
}