generated from template/apps-template
20 lines
524 B
TypeScript
20 lines
524 B
TypeScript
|
|
// base
|
|
import { app } from '../app.ts';
|
|
import './noco/index.ts';
|
|
|
|
// 添加认证中间件路由
|
|
const hasAuth = app.router.routes.some(r => r.id === 'auth');
|
|
if (!hasAuth) {
|
|
console.log('添加认证中间件路由');
|
|
app.route({
|
|
path: 'auth',
|
|
key: 'auth',
|
|
description: '用户认证',
|
|
id: 'auth'
|
|
}).define(async (ctx) => {
|
|
// 这里可以添加实际的认证逻辑
|
|
ctx.query.token = process.env.TOKEN || ' ';
|
|
console.log('本地测试认证通过,设置 token');
|
|
}).addTo(app);
|
|
} |