pluvial / svelte-adapter-deno

A SvelteKit adapter for Deno
https://svelte-adapter-deno.deno.dev/
MIT License
313 stars 14 forks source link

[Bug] TypeError: Cannot read properties of null (reading 'trailing_slash') #8

Closed und3fined closed 2 years ago

und3fined commented 2 years ago

Hi there,

Currently, I find a replace solution for ReactJS/Vuejs. And i choose Svelte

I use adapter withSvelteKit demo app no any change in code But I get a bug with router

TypeError: Cannot read properties of null (reading 'trailing_slash')
    at respond (file:///project-workspace/svelkit/build/app.js:1285:41)
    at render (file:///project-workspace/svelkit/build/app.js:1720:10)
    at file:///project-workspace/svelkit/build/server.js:73:27
    at async Layer.handle [as handle_request] (https://deno.land/x/opine@1.3.3/src/router/layer.ts:76:5)

Workflow:

  1. Add adapter to svelte.config.js
  2. Build sveltekit with npm run build
  3. Open http://localhost:3000
  4. Click to pages Home, About, Todo workfine
  5. But in /todo page, with a refresh i get a error with trailing_slash

Any reply for fix it?

und3fined commented 2 years ago

after review a guide for custom adapter So, deno adapter maybe out of date.

Output code that:
    - Calls init   <----- no call init
    - Converts from the platform's request to a SvelteKit request, calls render, and converts from a SvelteKit response to the platform's
    - Globally shims fetch to work on the target platform. SvelteKit provides a @sveltejs/kit/install-fetch helper for platforms that can use node-fetch

I added a pull request (https://github.com/pluvial/svelte-adapter-deno/pull/9), please accept it.

jpaquim commented 2 years ago

Hey, thank you very much for your input! I've started to work on a more comprehensive sync with the upstream changes to Svelte Kit and the adapter API, I'm still mid-way through reviewing the changes, and still a lot of testing to do, but it's already functional, you can track the development here: https://github.com/pluvial/svelte-adapter-deno/pull/10

und3fined commented 2 years ago

Hi @jpaquim,

Currently, i'm work in a fork of svelte/adapter-node in here! I use oak as Deno HTTP server and add more middleware for adapter, it maybe help more information run in Deno

A problem is your svelte-adapter-deno no any allow middleware. It's a feature?

jpaquim commented 2 years ago

Cool! I'll take a look at your work, when I started I decided to go for opine instead of oak due to it being more Express-like, and being relatively similar in API to the Node adapter's polka server. But I really like Koa, I need to give oak a try.

As for middleware, it should be possible to add custom opine-compatible middleware in a custom app instance, by overriding the deps.ts file. To make it more flexible, however, it would probably make sense to expose some kind of createServer-like programmatic API, but I guess the main purpose, similar to the Node adapter, is to serve as a baseline implementation of what an adapter/server can look like.

jpaquim commented 2 years ago

Hey @und3fined! I have since also decided to move to oak, if you're still interested you can take a look at the implementation, I've also been thinking more about external middleware support. Did you manage to get it working for your use case?

und3fined commented 2 years ago

Hi @jpaquim Currently, I not focus to Deno, my work focus make Svelte work in golang, support SSR, SSG. Svelte Kit perfect for start, but i want to control server and Svelte as frontend. I completed my first goal, make svelte kit (SSR) run in golang, but more function can't work. In my mind, the next goal, maybe i'll make a tool like svelte kit.