New: LICENSEファイル / Del: package.json.license / Feat: setup/initializationでVAPIDを生成 / Fix: 全てのエンドポイントでsuccessをレスポンス / Chg: input_noneエラーを廃止。入力がない場合は{}として解決する / Feat: フロントエンドでserver-infoを読み込む

This commit is contained in:
2026-03-22 20:48:28 +09:00
parent 841553a1ef
commit 60a87d4709
21 changed files with 828 additions and 54 deletions
+2 -1
View File
@@ -14,7 +14,6 @@
"email": "info@last2014.com",
"url": "https://about.last2014.com"
},
"license": "AGPL-3.0-only",
"packageManager": "pnpm@10.29.1",
"dependencies": {
"@fastify/static": "^9.0.0",
@@ -22,6 +21,7 @@
"@mikro-orm/migrations": "^6.6.7",
"@mikro-orm/postgresql": "^6.6.7",
"@mikro-orm/reflection": "^6.6.7",
"@types/web-push": "^3.6.4",
"argon2": "^0.44.0",
"cross-env": "^10.1.0",
"fastify": "^5.7.4",
@@ -33,6 +33,7 @@
"typescript": "^5.9.3",
"util": "^0.12.5",
"uuid": "^13.0.0",
"web-push": "^3.6.7",
"yaml": "^2.8.2",
"zod": "^4.3.6"
},
+1 -14
View File
@@ -32,14 +32,6 @@ try {
fastify.setErrorHandler((err, req, res) => {
res.header("Content-Type", "application/json");
if (err instanceof SyntaxError && /JSON/.test(err.message)) {
return res.status(400).send(ErrorBase({
bad: "client",
code: "input_none",
message: "入力がありません。",
}));
}
const customLogger = new Logger("Unknown(Error handler)");
customLogger.error("Unknown error:", err);
@@ -127,12 +119,7 @@ try {
done(null, json);
} catch (err) {
if (err instanceof Error) {
(err as any).statusCode = 400;
done(err, undefined);
} else {
done(new Error("Invalid JSON"), undefined);
}
done(null, {});
}
});
@@ -15,6 +15,7 @@ export default async function ServerInfo(fastify: FastifyInstance) {
const userCount = await user.count();
return res.send({
success: true,
isInitialized: configCount > 0,
isFirstAdminExists: userCount > 0,
userCount,
@@ -2,6 +2,7 @@ import { DatabaseError, ErrorBase, InputError } from "@/errors";
import Logger from "@/lib/logger";
import { ConfigEntity } from "@/modules/entities/Config";
import type { FastifyInstance } from "fastify";
import { generateVAPIDKeys } from "web-push";
import z from "zod/v3";
export default function SetupInitialization(fastify: FastifyInstance) {
@@ -46,6 +47,10 @@ export default function SetupInitialization(fastify: FastifyInstance) {
try {
const entries = Object.entries(result.data).filter(([key]) => key !== "force");
const vapid = generateVAPIDKeys();
entries.push(["VAPID_PUBLIC", vapid.publicKey]);
entries.push(["VAPID_PRIVATE", vapid.privateKey]);
for (const [key, value] of entries) {
const entity = await fastify.orm.em.getRepository(ConfigEntity).set(