更新数据库配置,添加默认时间戳,优化轻代码路由处理,新增示例代码文件

This commit is contained in:
2026-01-26 03:46:32 +08:00
parent 0e350b1bca
commit 3464bd240b
5 changed files with 127 additions and 67 deletions

View File

@@ -0,0 +1,44 @@
import { app, showMore, showRes } from './common.ts';
import crypto from 'node:crypto';
export const getStringHash = (str: string) => {
return crypto.createHash('md5').update(str).digest('hex');
}
const code = `// 这是一个示例代码文件
import {App} from '@kevisual/router';
const app = new App();
app.route({
path: 'hello',
description: 'LightCode 示例路由',
metadata: {
tags: ['light-code', 'example'],
},
}).define(async (ctx) => {
console.log('tokenUser:', ctx.query?.tokenUser);
ctx.body = 'Hello from LightCode!';
}).addTo(app);
app.wait();`
const code2 = `const a = 1`
const res = await app.run({
path: 'light-code',
key: 'update',
payload: {
data: {
title: 'Demo Light Code',
description: '这是一个演示用的轻代码项目,包含一个简单的路由示例。',
type: 'light-code',
tags: ['demo', 'light-code'],
data: {},
code: code,
hash: getStringHash(code),
},
token: "st_idht7xpffhgu2eeh94zd8ze1t7ew3amy",
},
})
console.log('showMore', showMore(res));