elysia
elysia copied to clipboard
Sveltekit integration doesn't work
What version of Elysia is running?
1.1.5
What platform is your computer?
Linux 6.9.12-200.fc40.x86_64 x86_64 unknown (I'm running Fedora 40)
What steps can reproduce the bug?
Hi! I've followed this page and I have a realy weird behavior. Every time I try to make navigate to route, it downloads content of page as a file. When I try to navigate to page with a swagger plugin, app just crashes with this error:
6628 | if (plugin2 instanceof _Elysia) return this._use(plugin2);
6629 | if (typeof plugin2.default === "function")
6630 | return plugin2.default(this);
6631 | if (plugin2.default instanceof _Elysia)
6632 | return this._use(plugin2.default);
6633 | throw new Error(
^
error: Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.
at /home/winet/Documents/JS Projects/enxperts/node_modules/elysia/dist/index.mjs:6633:17
Here the code that I'm using:
// /src/routes/api/[...slugs]/+server.ts
import type { RequestHandler } from '@sveltejs/kit';
import { app } from "$api";
export const GET: RequestHandler = ({ request }) => app.handle(request);
export const PUT: RequestHandler = ({ request }) => app.handle(request);
export const DELETE: RequestHandler = ({ request }) => app.handle(request);
export const POST: RequestHandler = ({ request }) => app.handle(request);
export const PATCH: RequestHandler = ({ request }) => app.handle(request);
export const fallback: RequestHandler = ({ request }) => app.handle(request);
// /src/lib/server/api/index.ts ($api)
import { swagger } from "@elysiajs/swagger";
import { Elysia } from "elysia";
export const app = new Elysia({prefix: '/api'})
.use(swagger())
.get('/', () => 'hi')
.get('/hello', () => 'world')
What is the expected behavior?
Just work™
What do you see instead?
Additional information
I'm starting app with this command bun --bun run dev
Have you try removing the node_modules
and bun.lockb
and try again yet?
yes