lane711 / sonicjs

SonicJs Headless CMS - Blazing Fast Headless CMS built on Cloudflare Workers. 100% Javascript Based
https://sonicjs.com
837 stars 115 forks source link

Hello World example in routing is broken #254

Open kilna opened 4 months ago

kilna commented 4 months ago

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 commented 4 months ago

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.