Coder Social home page Coder Social logo

Allow for no view engine about kraken-js HOT 17 CLOSED

krakenjs avatar krakenjs commented on May 14, 2024
Allow for no view engine

from kraken-js.

Comments (17)

totherik avatar totherik commented on May 14, 2024

Hey @djrenren, you should be able to use the express response directly for that. More here: http://expressjs.com/api.html#res.send. Is that what you're looking to do?

from kraken-js.

totherik avatar totherik commented on May 14, 2024

Ah, you don't even want one configured and ignored?

from kraken-js.

pvenkatakrishnan avatar pvenkatakrishnan commented on May 14, 2024

Like a web server. Cool request. Is there a reason you cant use vanilla express, maybe something else in kraken that you'd like to make use i guess.

from kraken-js.

djrenren avatar djrenren commented on May 14, 2024

@totherik - Correct, currently my project has to list dustjs-linkedin, dustjs-helpers, and adaro as dependencies otherwise I encounter startup failures. I'd like to get rid of this need.

@pvenkatakrishnan - I really like the lifecycle options as well as the structure for controllers and configuration. It makes working with a team a lot more convenient.

from kraken-js.

totherik avatar totherik commented on May 14, 2024

FIxed with PR #61

from kraken-js.

poorgeek avatar poorgeek commented on May 14, 2024

It appears that after the kraken.next (#114) code was merged in that the ability to opt out of a view engine is no longer available. Even the documentation on how to opt out of the view rendering (#72) is missing from the README.

Did this issue regress or maybe there's a better way to handle this now that hasn't been documented?

from kraken-js.

totherik avatar totherik commented on May 14, 2024

Hey @poorgeek, actually, unless you use the generator no view engine is configured by default, e.g. when you res.render you get this:

Error: No default engine was specified and no extension was provided.

and with the generator you can simply choose 'None' at the template library question and express will not be configured with a view engine.

Express settings are documented here.

from kraken-js.

poorgeek avatar poorgeek commented on May 14, 2024

@totherik I know this isn't the best place to figure this out, but I'm getting the "No default engine" error even though I've made sure that my generated app has all of the proper configs that are in an app generated with the 1.1.0 generator. I'm also not calling res.render anywhere in the app since I'm using kraken to build out an api which is rendering all of the responses to json. This is why I'm wondering if there's a regression happening.

from kraken-js.

totherik avatar totherik commented on May 14, 2024

Interesting. I'm not completely familiar with what the 1.1.0 version of the generator creates by default, but do you have expressView, fileNotFound, and serverError middleware configured in config/app.json? expressView should be a noop if you have nothing enabled, but the error handling middleware assume a renderer, I believe. If you have them can you try removing them? You'll also probably want to remove devtools from config/development.json as it's mainly intended for UI artifacts. Let me know what you find.

from kraken-js.

pvenkatakrishnan avatar pvenkatakrishnan commented on May 14, 2024

is it possible for us to take a look at it on github somewhere ? I used the latest generator to create a sample without view engines...
I had to remove the res.render from the default controller (which could be pre generated to not do that), but once i changed that, it worked fine.
https://github.com/pvenkatakrishnan/Kraken-NoViewEngine

from kraken-js.

pvenkatakrishnan avatar pvenkatakrishnan commented on May 14, 2024

I agree there can be a few modifications done when no view engine is selected which i will file as an issue against the generator.

from kraken-js.

pvenkatakrishnan avatar pvenkatakrishnan commented on May 14, 2024

Looks like there is already one krakenjs/generator-kraken#115

from kraken-js.

poorgeek avatar poorgeek commented on May 14, 2024

@pvenkatakrishnan I actually generated a NoView and a View project (using the generators defaults) and diff'd the two projects just to see what was different. I then diff'd the NoView project with my project and found that we were using an older version of engine-munger (0.1.3) and that we were missing the expressView middleware from our config.json. We are using the devtools, but only in our config/development.json (which was generated), though I'm not testing against that env.

My theory is that when something goes wrong in the code that throws an error condition (404, 500, etc..) that express is still trying to render a view even though its been configured not to display views. So maybe I'm missing a configuration somewhere that should be returning a json response instead.

from kraken-js.

pvenkatakrishnan avatar pvenkatakrishnan commented on May 14, 2024

ahhh gotcha. Let me generate a 500 error to see what happens....

from kraken-js.

pvenkatakrishnan avatar pvenkatakrishnan commented on May 14, 2024

You were right, by default the config was still trying to render 500 and 404 views provided within the kraken-js module (which need to be changed in the generator as well). but once i added customized error handling, it worked....
Check this out... https://github.com/pvenkatakrishnan/Kraken-NoViewEngine/blob/master/config/config.json#L29

from kraken-js.

jasisk avatar jasisk commented on May 14, 2024

Capturing these concerns in krakenjs/generator-kraken#115.

from kraken-js.

poorgeek avatar poorgeek commented on May 14, 2024

@pvenkatakrishnan that got it! Thank you!

from kraken-js.

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.