feat: initial prototype works

I can log in and create a book! Woo!
This commit is contained in:
2026-02-04 12:17:05 -08:00
parent e167a17bd9
commit b6d66d34cb
44 changed files with 3695 additions and 493 deletions
+2 -4
View File
@@ -9,9 +9,6 @@ declare module "fastify" {
authenticate: (request: FastifyRequest) => Promise<void>;
oauth2Discord: any;
}
interface FastifyRequest {
user?: any;
}
}
const authPlugin: FastifyPluginAsync = async (app) => {
@@ -30,6 +27,7 @@ const authPlugin: FastifyPluginAsync = async (app) => {
// Register Discord OAuth2
app.register(fastifyOauth2, {
name: "oauth2Discord",
scope: ["identify", "email"],
credentials: {
client: {
id: process.env.DISCORD_CLIENT_ID || "",
@@ -38,7 +36,7 @@ const authPlugin: FastifyPluginAsync = async (app) => {
auth: fastifyOauth2.DISCORD_CONFIGURATION,
},
startRedirectPath: "/api/auth/login",
callbackUri: `${process.env.API_URL || "http://localhost:3000"}/api/auth/callback`,
callbackUri: `${process.env.BASE_URL || "http://localhost:3000"}/api/auth/callback`,
});
// Authentication decorator
+32
View File
@@ -0,0 +1,32 @@
/**
* @copyright 2026 NHCarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { FastifyInstance } from "fastify";
import fastifyStatic from "@fastify/static";
import path from "path";
export default async function staticPlugin(app: FastifyInstance) {
const isProduction = process.env.NODE_ENV === "production";
if (isProduction) {
// Serve the built Angular app from dist directory
await app.register(fastifyStatic, {
root: path.join(__dirname, "../../../../../../dist/apps/frontend"),
prefix: "/", // Serve at root
wildcard: false, // Disable wildcard routes to avoid conflicts
});
// Catch-all route for Angular SPA routing (must be registered after API routes)
app.setNotFoundHandler((request, reply) => {
// Only catch routes that don't start with /api
if (!request.url.startsWith("/api")) {
reply.sendFile("index.html");
} else {
reply.code(404).send({ error: "Not Found" });
}
});
}
}