更新数据模式,增加代码数组最大值至65535;修改主页标题为“ESP32 微弱压力数据采集系统”;调整记录页面的EMA参数默认值和启用状态;更新ESLint配置以关闭no-explicit-any规则提示
This commit is contained in:
@@ -4,7 +4,7 @@ import { prisma } from '@/src/lib/prisma'
|
||||
import { applyFit, basicStats, genId, getSampleRateHz } from '@/src/lib/utils'
|
||||
|
||||
const DataSchema = z.object({
|
||||
code: z.array(z.number().int()).min(1, 'code array empty').max(4096, 'too many points'),
|
||||
code: z.array(z.number().int()).min(1, 'code array empty').max(65535, 'too many points'),
|
||||
fit: z.object({ a: z.number(), b: z.number() }).optional(),
|
||||
recStartMs: z.number().int().nonnegative().optional(),
|
||||
recEndMs: z.number().int().nonnegative().optional(),
|
||||
@@ -16,10 +16,12 @@ export async function POST(req: NextRequest) {
|
||||
const parsed = DataSchema.safeParse(json)
|
||||
if (!parsed.success) {
|
||||
const first = parsed.error.errors[0]
|
||||
console.log(first, json);
|
||||
|
||||
return Response.json({ error: first?.message ?? 'invalid body' }, { status: 400 })
|
||||
}
|
||||
const { code, fit, recStartMs, recEndMs } = parsed.data
|
||||
if (code.length > 16384) {
|
||||
if (code.length > 65535) {
|
||||
return Response.json({ error: 'payload too large' }, { status: 413 })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user