Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello World example in routing is broken #254

Open
kilna opened this issue May 3, 2024 · 1 comment
Open

Hello World example in routing is broken #254

kilna opened this issue May 3, 2024 · 1 comment

Comments

@kilna
Copy link

kilna commented May 3, 2024

Submitting as a GitHub error since there's no apparent way to contact the author.

The example at: https://sonicjs.com/routing#hello-world

Results in:

npm run dev

> sonicjs@0.0.3 dev
> run-p dev:*


> sonicjs@0.0.3 dev:esbuild
> node ./src/cms/util/build.mjs


> sonicjs@0.0.3 dev:wrangler
> wrangler pages dev dist --env development --port 8786

✘ [ERROR] Could not resolve "./cms/api/hello"

    src/server.ts:12:22:
      12 │ import { hello } from './cms/api/hello';
         ╵                       ~~~~~~~~~~~~~~~~~

/Users/kilna/Code/kilna/sonicjs/node_modules/esbuild/lib/main.js:1636
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
src/server.ts:12:22: ERROR: Could not resolve "./cms/api/hello"
    at failureErrorWithLog (/Users/kilna/Code/kilna/sonicjs/node_modules/esbuild/lib/main.js:1636:15)
    at /Users/kilna/Code/kilna/sonicjs/node_modules/esbuild/lib/main.js:1048:25
    at /Users/kilna/Code/kilna/sonicjs/node_modules/esbuild/lib/main.js:1512:9 {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 22,
        file: 'src/server.ts',
        length: 17,
        line: 12,
        lineText: "import { hello } from './cms/api/hello';",
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Could not resolve "./cms/api/hello"'
    }
  ],
  warnings: []
}

Node.js v21.6.1
ERROR: "dev:esbuild" exited with 1.

The import line has an incorrect path, it should be:

import { hello } from './custom/hello';

Furthermore the URL presented to test if it works or not should be http://localhost:8786/hello instead of http://localhost:8786/v1/hello (or the app.route needs to include the v1).

I really like the concept of this project, but that was a bit of a rocky start.

@kilna
Copy link
Author

kilna commented May 3, 2024

Also when going through the setup steps this one:

wrangler d1 create SonicJS

Just hung there... I suspect it's the mixed case name? I was able to create a lowercase name via the CF web ui instead. I didn't try from wrangler, it may have worked. It's probably a CF bug that it hangs, but your examples should probably all use lowercase for consistency with CF's expectations; the preview and non-preview KV stores are named in different cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant