mirror of
https://github.com/detleph/server.git
synced 2026-09-04 00:26:03 +02:00
Add express.static() to serve semi-static files
+ Should be user-updateable in the future
This commit is contained in:
@@ -111,3 +111,6 @@ host/
|
||||
|
||||
# Ignore flags
|
||||
INITIALIZED
|
||||
|
||||
# Ignore runtime files
|
||||
media/
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import express from "express";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// Media storage with express static (Should only handle GET and HEAD request methods)
|
||||
router.use("/", express.static("media", { redirect: false }));
|
||||
|
||||
export default router;
|
||||
@@ -11,6 +11,7 @@ import roleSchemaRouter from "./Routes/role_schema.routes";
|
||||
import defaultErrorHandler from "./Middleware/error/handler";
|
||||
import logger from "./Middleware/error/logger";
|
||||
import debugLogger from "./Middleware/debug/logger";
|
||||
import mediaRouter from "./Routes/media.routes";
|
||||
|
||||
// Set up async error handling
|
||||
require("express-async-errors");
|
||||
@@ -51,6 +52,7 @@ async function main() {
|
||||
|
||||
app.use("/api/admins", adminRouter);
|
||||
|
||||
<<<<<<< HEAD
|
||||
app.use("/api/organisations", organisationRouter);
|
||||
|
||||
app.use("/api/groups", groupRouter);
|
||||
@@ -61,6 +63,9 @@ async function main() {
|
||||
|
||||
// Error handling
|
||||
app.use(defaultErrorHandler); // Not working
|
||||
=======
|
||||
app.use("/api/media", mediaRouter);
|
||||
>>>>>>> Add express.static() to serve semi-static files
|
||||
|
||||
app.listen(process.env.PORT, () => {
|
||||
logger.info(`Listening on port ${process.env.PORT}`);
|
||||
|
||||
Reference in New Issue
Block a user