更新数据库配置,添加默认时间戳,优化轻代码路由处理,新增示例代码文件
This commit is contained in:
@@ -81,6 +81,7 @@ app
|
||||
path: 'light-code',
|
||||
key: 'update',
|
||||
middleware: ['auth'],
|
||||
isDebug: true,
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
@@ -111,16 +112,28 @@ app
|
||||
ctx.body = null;
|
||||
}
|
||||
} else {
|
||||
const [created] = await db
|
||||
.insert(schema.kvContainer)
|
||||
.values({
|
||||
...container,
|
||||
uid: tokenUser.id,
|
||||
})
|
||||
.returning();
|
||||
ctx.body = created;
|
||||
try {
|
||||
|
||||
console.log('created', container, 'userId', tokenUser.id);
|
||||
const [created] = await db
|
||||
.insert(schema.kvContainer)
|
||||
.values({
|
||||
title: container.title || '',
|
||||
description: container.description || '',
|
||||
type: container.type || 'light-code',
|
||||
code: container.code || '',
|
||||
data: container.data || {},
|
||||
tags: container.tags || [],
|
||||
hash: container.hash || '',
|
||||
uid: tokenUser.id,
|
||||
})
|
||||
.returning();
|
||||
ctx.body = created;
|
||||
} catch (error) {
|
||||
console.error('Error creating container:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user