✅ Option for static files directory #249
Replies: 7 comments 1 reply
-
Well... This method is currently available when using |
Beta Was this translation helpful? Give feedback.
-
Returning app actually sounds awesome, especially as it seems to solve another idea I had of allowing express-zod-api to work with next's without breaking its auto-deployment feature. |
Beta Was this translation helpful? Give feedback.
-
It seems like this doesn't actually work. |
Beta Was this translation helpful? Give feedback.
-
Thank you for checking this out, @Isaac-Leonard . |
Beta Was this translation helpful? Give feedback.
-
A solution might be perhaps only mounting the express-zod-api handler on the actual routes and let express handle the routing so that it doesn't conflict with custom routes attached after express-zod-api has been initialised but then that might be unstable / bug prone. |
Beta Was this translation helpful? Give feedback.
-
I came up with idea to provide a method import {Routing, serveStatic} from "express-zod-api";
const routing: Routing = {
// path /public serves static files from /example/assets
public: serveStatic(path.join(__dirname, "assets"), {
dotfiles: "deny",
index: false,
redirect: false,
}),
}; |
Beta Was this translation helpful? Give feedback.
-
Finally I made a decision to change it slightly and make it a class, so it will be also consistent with usage of import {Routing, ServeStatic} from "express-zod-api";
const routing: Routing = {
// path /public serves static files from ./assets
public: new ServeStatic(path.join(__dirname, "assets"), {
dotfiles: "deny",
index: false,
redirect: false,
}),
}; |
Beta Was this translation helpful? Give feedback.
-
In express there's a .static() method to specify where plain html / css / frontend js / * files are located, would it be possible to add this to the config object please?
Beta Was this translation helpful? Give feedback.
All reactions