Git Product home page Git Product logo

Comments (5)

xtuc avatar xtuc commented on June 17, 2024

I intentially didn't do it to avoid adding a D1 query on all requests.

from wildebeest.

petebacondarwin avatar petebacondarwin commented on June 17, 2024

But don't we hit D1 on every frontend UI request anyway? Especially now that we are reading the thumbnail etc from the DB?
In the data loader for access the instance-config, we could trigger a redirect if no data is returned.

from wildebeest.

xtuc avatar xtuc commented on June 17, 2024

We would need to query D1 to detect that the instance hasn't been configured.

from wildebeest.

petebacondarwin avatar petebacondarwin commented on June 17, 2024

This code runs on every frontend request:

export const instanceLoader = loader$<{ DATABASE: D1Database; domain: string }, Promise<InstanceConfig>>(
async ({ platform }) => {
const response = await instance.handleRequest('', platform.DATABASE)
const results = await response.text()
const json = JSON.parse(results) as InstanceConfig
return json
}
)

In this function, we can check whether the config exists (rather than just naively casting it) and throw a response.redirect() to push the user to the start-instance page instead.

from wildebeest.

petebacondarwin avatar petebacondarwin commented on June 17, 2024

And if this is problematic (from a performance point of view) we need to implement some caching of the instance data in the system somewhere (outside of D1) perhaps in a KV?

from wildebeest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.