Refactor project to transition from Rust backend to Node.js with Fastify; update Dockerfile and Docker configurations for new build process; enhance local development instructions in CONTRIBUTING.md; implement health checks in Docker Compose; update pnpm-lock.yaml with new dependencies for API and shared packages; revise README.md to reflect new stack and development setup.
Build, Test, and Push CFDM Docker Image / test (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / create-release (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / test (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / create-release (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been cancelled
This commit is contained in:
1 parent
0a0a1a92f1
commit
d11414666f
2065 files changed
+15782
-16699
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import type { FastifyInstance } from "fastify";
|
||||
import { z } from "zod";
|
||||
import { healthCheck } from "../plugins/db.js";
|
||||
import * as authService from "../services/auth.js";
|
||||
|
||||
export async function healthRoutes(app: FastifyInstance) {
|
||||
app.get("/health", async (request, reply) => {
|
||||
healthCheck(request.server.sqlite);
|
||||
return { status: "ok" };
|
||||
});
|
||||
|
||||
app.get("/ready", async (request, reply) => {
|
||||
healthCheck(request.server.sqlite);
|
||||
let cloudflare = false;
|
||||
if (request.server.config.cloudflareApiToken) {
|
||||
try {
|
||||
await request.server.cf.listZones();
|
||||
cloudflare = true;
|
||||
} catch {
|
||||
cloudflare = false;
|
||||
}
|
||||
}
|
||||
return {
|
||||
status: cloudflare || !request.server.config.cloudflareApiToken
|
||||
? "ready"
|
||||
: "degraded",
|
||||
database: true,
|
||||
cloudflare,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function authRoutes(app: FastifyInstance) {
|
||||
const loginSchema = z.object({
|
||||
username: z.string(),
|
||||
password: z.string(),
|
||||
});
|
||||
|
||||
app.post("/auth/login", async (request, reply) => {
|
||||
const body = loginSchema.parse(request.body);
|
||||
const result = await authService.login(
|
||||
request.server.config,
|
||||
(payload) => request.server.jwt.sign(payload),
|
||||
body,
|
||||
);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user