feat: add fill-assist handlers and update device response type

This commit is contained in:
shuaiplus
2026-07-01 13:28:22 +08:00
parent 5dd9dff045
commit e4215b4025
4 changed files with 57 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
const EMPTY_FORMS_FILENAME = 'forms.v1.json';
const EMPTY_FORMS_BODY = JSON.stringify({
schemaVersion: '1.0.0',
hosts: {},
});
const EMPTY_MANIFEST_BODY = JSON.stringify({
maps: {
forms: {
v1: {
filename: EMPTY_FORMS_FILENAME,
cid: 'sha256:nodewarden-empty-fill-assist-v1',
},
},
},
});
function fillAssistJsonResponse(body: string): Response {
return new Response(body, {
status: 200,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Cache-Control': 'public, max-age=3600',
},
});
}
export function handleFillAssistManifest(): Response {
return fillAssistJsonResponse(EMPTY_MANIFEST_BODY);
}
export function handleFillAssistForms(filename: string): Response {
if (String(filename || '').trim() !== EMPTY_FORMS_FILENAME) {
return new Response('Not found', { status: 404 });
}
return fillAssistJsonResponse(EMPTY_FORMS_BODY);
}