gtrabanco / elysia-hmr-html

9 stars 0 forks source link

error within first line #1

Closed t0mri closed 11 months ago

t0mri commented 1 year ago
import { hmr } from "@gtrabanco/elysia-hmr-html";

new Elysia()
  .use(hmr({ prefixToWatch: "src" }))
[{
    "resource": "/T:/Projects/AGSCraft/labs/rough/src/server.tsx",
    "owner": "typescript",
    "code": "2769",
    "severity": 8,
    "message": "No overload matches this call.\n  The last overload gave the following error.\n    Argument of type 'Elysia<\"\", { request: {}; store: {}; }, { type: {}; error: {}; }, { body: unknown; headers: unknown; query: unknown; params: unknown; cookie: unknown; response: unknown; }, { [x: string]: { get: { body: unknown; params: unknown; query: unknown; headers: unknown; response: { 200: Response; }; }; }; }, false>' is not assignable to parameter of type 'Promise<{ default: Elysia<any, any, any, any, any, any>; }>'.\n      Type 'Elysia<\"\", { request: {}; store: {}; }, { type: {}; error: {}; }, { body: unknown; headers: unknown; query: unknown; params: unknown; cookie: unknown; response: unknown; }, { [x: string]: { get: { body: unknown; params: unknown; query: unknown; headers: unknown; response: { 200: Response; }; }; }; }, false>' is missing the following properties from type 'Promise<{ default: Elysia<any, any, any, any, any, any>; }>': then, catch, finally, [Symbol.toStringTag]",
    "source": "ts",
    "startLineNumber": 15,
    "startColumn": 8,
    "endLineNumber": 15,
    "endColumn": 37,
    "relatedInformation": [
        {
            "startLineNumber": 390,
            "startColumn": 5,
            "endLineNumber": 390,
            "endColumn": 8,
            "message": "The last overload is declared here.",
            "resource": "/t:/Projects/AGSCraft/labs/rough/node_modules/elysia/dist/index.d.ts"
        }
    ]
}]
gtrabanco commented 1 year ago

Have you seen the folder example?

This plugin does not serve static folder, you need and additional plugin for that. You need to serve html content from any endpoint and provide a folder to watch for changes as you do.

You also need to provide .listen method to run elysia.

gtrabanco commented 11 months ago

Close due no answer or any actions from author. If you still have similar issues please reopen it.

t0mri commented 11 months ago

now what?

new Elysia()
    .use(hmr({ prefixToWatch: "src" }))
    .use(staticPlugin({ assets: "src", prefix: "/public" }))
    .get(`/`, () => `hello`)
    .listen(3000, ({ hostname, port }) => {
        console.log(`🦊 running on http://${hostname}:${port}`);
    });

my file structure

project
    |- node_modules
    |- src
        |- index.ts
gtrabanco commented 11 months ago

You need an src/public directory, it will fail if it does not exists. You must have also html files inside.

It will look for changes in any file but it will refresh only html content type so if you response with a content type text/plain as you do you won't see any updates.

If you change content in any javascript or typescript file you should use --watch with bun because the content won't change unless the module file is reloaded.

t0mri commented 11 months ago

well the thing im tryna do is out this projects scope ig