更新 package.json 版本号至 0.0.12;优化 isLocalhost 函数以处理空主机名;修复 handleRequest 中对 dns.hostName 的访问;在轻代码列表中添加 code 字段;更新示例路由描述

This commit is contained in:
2026-01-26 04:24:00 +08:00
parent 3464bd240b
commit 27f170ae2b
5 changed files with 8 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@kevisual/code-center", "name": "@kevisual/code-center",
"version": "0.0.11", "version": "0.0.12",
"description": "code center", "description": "code center",
"type": "module", "type": "module",
"main": "index.js", "main": "index.js",

View File

@@ -27,6 +27,9 @@ export const getDNS = (req: http.IncomingMessage) => {
}; };
export const isLocalhost = (hostName: string) => { export const isLocalhost = (hostName: string) => {
if(!hostName) {
return false;
}
return hostName.includes('localhost') || hostName.includes('192.168'); return hostName.includes('localhost') || hostName.includes('192.168');
}; };

View File

@@ -145,7 +145,7 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
let user, app; let user, app;
let domainApp = false; let domainApp = false;
const isDev = isLocalhost(dns.hostName); const isDev = isLocalhost(dns?.hostName);
if (isDev) { if (isDev) {
console.debug('开发环境访问:', req.url, 'Host:', dns.hostName); console.debug('开发环境访问:', req.url, 'Host:', dns.hostName);
} else { } else {

View File

@@ -34,6 +34,7 @@ app
type: schema.kvContainer.type, type: schema.kvContainer.type,
tags: schema.kvContainer.tags, tags: schema.kvContainer.tags,
data: schema.kvContainer.data, data: schema.kvContainer.data,
code: schema.kvContainer.code,
uid: schema.kvContainer.uid, uid: schema.kvContainer.uid,
createdAt: schema.kvContainer.createdAt, createdAt: schema.kvContainer.createdAt,
updatedAt: schema.kvContainer.updatedAt, updatedAt: schema.kvContainer.updatedAt,
@@ -42,7 +43,7 @@ app
.from(schema.kvContainer) .from(schema.kvContainer)
.where(and(...conditions)) .where(and(...conditions))
.orderBy(desc(schema.kvContainer.updatedAt)); .orderBy(desc(schema.kvContainer.updatedAt));
ctx.body = list; ctx.body = { list };
return ctx; return ctx;
}) })
.addTo(app); .addTo(app);

View File

@@ -11,7 +11,7 @@ const app = new App();
app.route({ app.route({
path: 'hello', path: 'hello',
description: 'LightCode 示例路由', description: 'LightCode 示例路由 2323232323',
metadata: { metadata: {
tags: ['light-code', 'example'], tags: ['light-code', 'example'],
}, },