feat: 更新sign的模块
This commit is contained in:
35
demo/simple/src/apps-https/app.ts
Normal file
35
demo/simple/src/apps-https/app.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Route, App } from '@kevisual/router';
|
||||
import { readFileSync } from 'fs';
|
||||
const app = new App({
|
||||
serverOptions: {
|
||||
cors: {},
|
||||
isHTTPS: true,
|
||||
httpsKey: readFileSync('https-key.pem', 'utf8'),
|
||||
httpsCert: readFileSync('https-cert.pem', 'utf-8'),
|
||||
},
|
||||
});
|
||||
app.listen(4003, '0.0.0.0', () => {
|
||||
console.log(`http://localhost:4003/api/router?path=demo&key=02`);
|
||||
console.log(`http://localhost:4003/api/router?path=demo&key=01`);
|
||||
console.log(`https://192.168.31.220:4003/api/router?path=demo&key=01`);
|
||||
});
|
||||
const route01 = new Route('demo', '01');
|
||||
route01.run = async (ctx) => {
|
||||
ctx.body = '01';
|
||||
return ctx;
|
||||
};
|
||||
app.use(
|
||||
'demo',
|
||||
async (ctx) => {
|
||||
ctx.body = '01';
|
||||
return ctx;
|
||||
},
|
||||
{ key: '01' },
|
||||
);
|
||||
|
||||
const route02 = new Route('demo', '02');
|
||||
route02.run = async (ctx) => {
|
||||
ctx.body = '02';
|
||||
return ctx;
|
||||
};
|
||||
app.addRoute(route02);
|
6
demo/simple/src/apps-https/create-sign.ts
Normal file
6
demo/simple/src/apps-https/create-sign.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createCert } from '@kevisual/router/sign';
|
||||
import { writeFileSync } from 'fs';
|
||||
const { key, cert } = createCert();
|
||||
|
||||
writeFileSync('https-key.pem', key);
|
||||
writeFileSync('https-cert.pem', cert);
|
Reference in New Issue
Block a user