Feat: server-infoエンドポイント / Fix: logger.tsを追跡対象に / Feat: lynqchat-jsを利用可能に / Fix: lynqchat-jsに不足していたエンドポイントを追加
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { DatabaseError } from "@/errors";
|
||||
import logger from "@/lib/logger";
|
||||
import { ConfigEntity } from "@/modules/entities/Config";
|
||||
import { UserEntity } from "@/modules/entities/User";
|
||||
import type { FastifyInstance } from "fastify";
|
||||
|
||||
export default async function ServerInfo(fastify: FastifyInstance) {
|
||||
fastify.post("/", async (req, res) => {
|
||||
try {
|
||||
const config = fastify.orm.em.getRepository(ConfigEntity);
|
||||
const user = fastify.orm.em.getRepository(UserEntity);
|
||||
const configCount = await config.count();
|
||||
const userCount = await user.count();
|
||||
|
||||
return res.send({
|
||||
isInitialized: configCount > 0,
|
||||
isFirstAdminExists: userCount > 0,
|
||||
userCount,
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error("Database error:", err);
|
||||
|
||||
return res.code(500).send(DatabaseError());
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user