更新数据库配置,添加默认时间戳,优化轻代码路由处理,新增示例代码文件
This commit is contained in:
44
src/test/add-demo-light-code.ts
Normal file
44
src/test/add-demo-light-code.ts
Normal 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));
|
||||
@@ -3,7 +3,9 @@ import '@/route.ts';
|
||||
import { useConfig, useContextKey } from '@kevisual/context';
|
||||
import { Query } from '@kevisual/query';
|
||||
import util from 'node:util';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
export {
|
||||
app,
|
||||
useContextKey
|
||||
|
||||
Reference in New Issue
Block a user