Open houssemFat opened 9 months ago
I can confirm the same thing. Wrapping the static plugin in a separate Elysia app, like this:
export const serveStaticFiles = new Elysia({ name: '~/lib/serveStatic' }).use(
staticPlugin(
NODE_ENV === 'development'
? {
headers: {
'Cache-Control':
'no-store, no-cache, must-revalidate, proxy-revalidate',
Expires: '0',
'Surrogate-Control': 'no-store',
Pragma: 'no-cache',
},
}
: {},
),
);
raises the following TypeScript error:
lib/serveStatic.ts:6:3 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'Promise<Elysia<"", { request: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, {}, {
}, {}, false>>' is not assignable to parameter of type 'Promise<{ default: Elysia<any, any, any, any, any, any, any>; }>'.
Property 'default' is missing in type 'Elysia<"", { request: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; erro
r: {}; }, {}, {}, {}, false>' but required in type '{ default: Elysia<any, any, any, any, any, any, any>; }'.
6 staticPlugin(
~~~~~~~~~~~~~
7 NODE_ENV === 'development'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
17 : {},
~~~~~~~~~~~
18 ),
~~~
Hi, @houssemFat did you find any workaround?
EDIT:
just found out that using .mount
instead of .use
works.
app.mount(SSRPlugin.fetch)
Hi , thank you for all the effort behind elysia and elysia-static.
Description
I'm trying to use a SSR plugin and i need the
elysia-static
plugin only on production. So i will check if i'm in prod or dev mode and i will use a custom plugin that will includeelysia-static
in the Elysia app (nested app for plugin). When we use the plugin in the main Elysia instance (the instance that acts as server) , the plugin works fine , but when we use it with a nested Elysia app (a plugin Elysia app), the plugin don't work as expected (I get 404).Below my folder structure.
Usage with the main Elysia instance : OK
Works fine when using the plugin with main Elysia instance. The
http://localhost:2000/assets/index-BRPLnx8F.js
url returns the file.main.js
Usage with Nested plugin : NOK
the
http://localhost:2000/assets/index-BRPLnx8F.js
returnsNOT_FOUND
SSRPlugin.js
main.js
Info