Initial commit: restore project after Git corruption
This commit is contained in:
46
server/code/root/light-code-demo/sign.ts
Normal file
46
server/code/root/light-code-demo/sign.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { QueryRouterServer as Mini } from "@kevisual/router";
|
||||
import { NocoApi } from "@kevisual/noco";
|
||||
const config = {
|
||||
NOCODB_URL: process.env.NOCODB_URL || 'https://nocodb.xiongxiao.me',
|
||||
NOCODB_API_KEY: process.env.NOCODB_API_KEY || 'uca1Zx3p_0pnNUBV6ot9mBP6JCPqQ0X1TF3N3R7s'
|
||||
}
|
||||
const table = 'mcby44q8zrayvn9'
|
||||
const nocoAPi = new NocoApi({
|
||||
baseURL: config.NOCODB_URL,
|
||||
token: config.NOCODB_API_KEY,
|
||||
table,
|
||||
});
|
||||
console.log('nocoAPi', await nocoAPi.record.list())
|
||||
const app = new Mini();
|
||||
|
||||
|
||||
app.route({
|
||||
path: 'sign'
|
||||
}).define(async (ctx) => {
|
||||
const { Title, Description } = ctx.query
|
||||
// 这里可以处理签到
|
||||
await nocoAPi.record.create({ Title, Description })
|
||||
const list = await nocoAPi.record.list({ sort: '-CreatedAt' })
|
||||
ctx.body = { message: '签到成功', list }
|
||||
}).addTo(app)
|
||||
|
||||
app.route({
|
||||
path: 'sign',
|
||||
key: 'list'
|
||||
}).define(async (ctx) => {
|
||||
// 这里可以处理签到
|
||||
ctx.body = await nocoAPi.record.list()
|
||||
}).addTo(app)
|
||||
|
||||
app.route({
|
||||
path: 'sign',
|
||||
key: 'delete'
|
||||
}).define(async (ctx) => {
|
||||
const { id } = ctx.query
|
||||
// 这里可以处理签到
|
||||
await nocoAPi.record.delete({ Id: id })
|
||||
const list = await nocoAPi.record.list({ sort: '-CreatedAt' })
|
||||
ctx.body = { message: '删除成功', list }
|
||||
}).addTo(app)
|
||||
|
||||
app.wait()
|
||||
Reference in New Issue
Block a user