Git Product home page Git Product logo

Comments (12)

andrewfluck avatar andrewfluck commented on June 8, 2024 1

nevermind I see what you mean

from spf-express.

andrewfluck avatar andrewfluck commented on June 8, 2024

@Arthelon I have an idea, can you add in a feature where you can specify the json in the route, that way I can read files as the route is requested.

from spf-express.

Arthelon avatar Arthelon commented on June 8, 2024

@newtsrock can you clarify what you mean? You can already specify json to be returned at each route.

from spf-express.

andrewfluck avatar andrewfluck commented on June 8, 2024

For example you could do

app.get('/', (req, res) => {
    // Include middleware function here
    // Include SPF JSON per each route inside middleware function
    res.render('layout', {
        // Instead of middleware function you could include the SPF JSON here in an SPF object.
    })
})

from spf-express.

Arthelon avatar Arthelon commented on June 8, 2024

Having to write your own express middleware defeats the purpose of this mini library. I still don't understand the res.render() example. Why are you trying to inject an SPF object into the template layer?

from spf-express.

andrewfluck avatar andrewfluck commented on June 8, 2024

Mainly because when I'm using the library and have to update the partial I'm loading into the object, I cant do it on a per request basis. I'd prefer a feature for that because when I load in the object in the middleware, it only gets requested once. Everytime I make a change to the partial, I need to restart the server because like I said, the middleware only gets loaded once.

from spf-express.

andrewfluck avatar andrewfluck commented on June 8, 2024

Btw the partial is the html content I'm swapping out

from spf-express.

Arthelon avatar Arthelon commented on June 8, 2024

@newtsrock It seems like you need hot module reloading or similar behavior. This would be too specific of a feature to implement. This library might be able to help for your use-case.

from spf-express.

andrewfluck avatar andrewfluck commented on June 8, 2024

Sounds good, I'll try it when I get home.

from spf-express.

andrewfluck avatar andrewfluck commented on June 8, 2024

@Arthelon I now need the library for dynamic data, I don't want the server to restart to get new data that gets fetched once per restart. Can you please consider my suggestion as that would be easy for me and my uses for it.

from spf-express.

Arthelon avatar Arthelon commented on June 8, 2024

Why is data being fetched once per restart? That implies that the fetching isn't being linked to any endpoints The library allows you to handle dynamic data by supplying an express middleware function to a path.

from spf-express.

andrewfluck avatar andrewfluck commented on June 8, 2024

@Arthelon I'm afraid I don't get what you mean, can you leave a sample?

from spf-express.

Related Issues (3)

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.