Node.js Integration in Wappler

For anyone else wondering… I fixed it.

After a number of fresh un/reinstall, turns out I had turned off the experimental features option the other day.

Turned it back on and restarted Wappler and it is working.

2 Likes

image

3 Likes

A post was split to a new topic: Hosting of NodeJS sites

10 posts were split to a new topic: Using NodeJS to create an offline desktop application

@Teodor, would it be possible to add Docker to the above tutorial?

You already cover “setting up a database connection”, but that would only apply (I think) if you’re not using Docker since Docker creates the database and it’s connection automatically.

Also there is talk in the other node.js threads on this forum about node.js having the web server already built in (unlike php). So I’m not clear on how Docker fits in with node.js in Wappler because Docker tends to build the web server along with the database.

Adding a bit to this tutorial (or as a separate tutorial) about how to use node.js with Docker in Wappler would be helpful and much appreciated.

2 Likes

3 posts were split to a new topic: NodeJS on MacOS Catalina - giving warning on fsevenets.node

Docker integration is still under development and it is coming up in the next betas.

1 Like

Quick question. When using Node.js what is the extension you would use? When I use php it is *.php. When I use html only, it is *.html or *.htm. And what is the naming for index.html when using Node.js.

1 Like

@BruceSchueller I had the same questions here particularly because when you create a node project the first file it creates is the index.ejs and puts it in a views folder and not “Public”

Public is for static assets.
Views for templates(ejs).

Check ExpressJS and EJS documentation to get a better understanding how these two folders work.

2 Likes

Had a look at the documentation and a little over my head at this stage so I signed up for a Udemy Node.js / Express course. Finally figured out how to fix the routing syntax, but conscious I just want to learn what I have to to build in Wappler, just don’t have the time to deep dive. I assume at some stage Wappler will make this all clearer.

1 Like

Yes. It takes a bit of time and learning(ExpressJS, EJS and Nodejs). But less than you imagine. All the pieces start to fall in their place in cascade once you understand the basics. Wappler does abstract you from that. But during Beta it’s important to know the basics or the feedback you provide won’t be as useful.

Express will serve files in public without preprocessing. So if you ask for a jpeg you will get the browser view for an image. If you ask for html and css the same. You would normally store in public css, images, client js, etc

In views, express will preprocess the files(similar to php). Any ejs templating code will be evaluated before being rendered to the browser. In views is where you define your layouts and partials(.ejs files) which are the core of your app.

2 Likes

Not sure what you mean?
The routing is automatically generated for you. If you follow what’s explained in the steps above.

That is true indeed. My advice is If you are not familiar with NodeJS and why/when is it used better wait until the final integration in 3.0 final before start working on a project, as the workflow and options may change.

1 Like

Hi @Teodor it didn’t before I created a Type Page route I selected a Type: URL and realised it was the wrong “Type” but it would not edit, just kept reverting back from page to URL. figured out where the file was and could see that the Page and the URL type syntax where included in the same reference to the page. So the only way I could fix it was go in the file and remove the URL reference type form the file now it works. Probably a bug, but wasn’t game to mention it!

What are you referring to exactly?
I am referring to the docs above (the first post of this topic). When you create a layout page and a content page from this layout using the Pages Manager, the routes are created automatically.
What were your steps exactly? Were they different than what is explained here?

Thanks @JonL, yep working through the Udemy course so figure I will eventually be a node.js and Express power user :crazy_face:

Converting a html page to and .ejs creating the route has to be done manually, because it doessn’t do it automatically, which was easy enough but it is when I experienced the “issue”, but I now know what is going on with .ejs files now and routing.

Ah ok i see, so you were not creating the pages in the Pages Manager as explained in this topic, but instead tried to convert them from html to ejs.

We will be improving that and also adding more integration with the pages manager for new files creation so people don’t create static files per accident

2 Likes

Well kind off, but I couldn’t work out the above example for routes, because the Routes properties doesn’t look like the images above, there is the “Type” drop down option is where I experienced the error.

It would be good to know when to use: “URL” vs “Page” vs “Content” so to find out I tried them.