From 4b51fb8325acafac4e9231754dc58663f6431e1e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 17 Jan 2023 12:33:17 -0800 Subject: rename app --- lib/app.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/app.js (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js new file mode 100644 index 00000000..af2bd59f --- /dev/null +++ b/lib/app.js @@ -0,0 +1,40 @@ +import config from "$config"; +import fastify from "fastify"; +import fastifyWs from "@fastify/websocket"; +import fastifyMultipart from "@fastify/multipart"; +import fastifyStatic from "@fastify/static"; +import fastifyPassport from "@fastify/passport"; +import fastifySecureSession from "@fastify/secure-session"; + +import path from "path"; +import pino from "pino"; + +import { jwtStrategy } from "$lib/auth"; +import { socketServer } from "$lib/sockets"; + +const app = fastify({ + logger: pino(), + disableRequestLogging: true, + maxParamLength: 500 +}); + +app.register(fastifySecureSession, { + key: Buffer.from(config.jwt, "hex") +}); + +app.register(fastifyPassport.initialize()); +app.register(fastifyPassport.secureSession()); + +fastifyPassport.use("jwt", jwtStrategy); + +app.register(fastifyMultipart); + +app.register(fastifyStatic, { + root: path.join("/app/uploads"), + prefix: "/public/" +}); + +app.register(fastifyWs); +app.register(socketServer); + +export default app; -- cgit v1.2.3 From 74704611d9c5772491488852b88db7e458b95610 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 25 Jan 2023 11:47:06 -0800 Subject: mv uploads --- lib/app.js | 2 +- lib/upload.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index af2bd59f..4691786a 100644 --- a/lib/app.js +++ b/lib/app.js @@ -30,7 +30,7 @@ fastifyPassport.use("jwt", jwtStrategy); app.register(fastifyMultipart); app.register(fastifyStatic, { - root: path.join("/app/uploads"), + root: path.join("/app/data/uploads"), prefix: "/public/" }); diff --git a/lib/upload.js b/lib/upload.js index 43cc35ce..fbf9ce20 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -20,7 +20,7 @@ export default async ({ params: { type }, file, user }, res) => { throw new Error("unsupported file type"); let name = `${user.id}-${type}.webp`; - let path = `/app/uploads/${name}`; + let path = `/app/data/uploads/${name}`; let size = type === "banner" ? 1920 : 240; let t = sharp() -- cgit v1.2.3