Ok, so how exactly start writing nodeJS code
I have a website running (hosted with Namecheap shared plan). I [create, update,] content frequently. To do that I use cPannel > File Manager to manually edit html [the file I need to /edit]. It’s kinda an okay way to update your content if you don’t got a choice, but upon doing some research, using Templating Engine is the way to do it. They say dJango is the best, but I’m going with NodeJS, since I’m familiar with JS. I learned to install nodeJS (on local computer), and display hello world.
4/16/2021 1:10:16 AM
Ginfio
9 Answers
New AnswerLooks like this might address that, even though the English is a bit wonky. hoststud.com/resources/how-to-create-a-node-js-application-with-cpanel-using-the-node-js-selector.730/ Cpanel does have its good aspects but I'm glad I don't have to deal with it daily anymore.
NodeJs is the way to run Javascript outside browser using Google V8 engine Google for any MERN/MEAN stack (Mongo + Express) boilerplate https://expressjs.com/ Its easy to learn since Mongo has the Mongoose driver and its a json database. Some basic tutorial https://auth0.com/blog/developing-well-organized-apis-with-nodejs-joi-and-mongo/ For anything more advanced/enterprise I recommend you search some ORM framework and use Typescript instead of Javascript https://expressjs.com/en/resources/frameworks.html Also read some tips about performance and clustering + https://expressjs.com/en/advanced/best-practice-performance.html + https://dev.to/joan41868/scaling-a-simple-node-js-express-js-application-using-node-js-modules-23bp + https://nodejs.org/api/cluster.html
In the web host, in the file cPannel, there’s an option “Create nodeJs application”. I created the application, but now what? Like... how can i write some code (node.). So i can make an api which i can use to edit/create content on my site
https://bhattaraipradip66.medium.com/how-to-deploy-a-node-js-application-through-cpanel-891ed374225a
```js const http = require("http"); const app = http.createServer((req, res) => { if(req.url === "/") { res.write("hello"); res.end(); } else { res.write("404: page not found") ; res.end(); } }); const port = process.env.PORT || 5000; app.listen(port); ``` This is with vanilla js. We often use express to create server. ```js const express = require("express") ; const app = express(); const port = process.env.PORT || 5000; app.get("/", (req, res) => { res.send("hello"); }) app.listen(port);
Ginfio mostly command line when I do anything with node (have some interesting mobile stuff) but I'm working on ecma stuff at the moment instead of node. If I were starting over knowing what I do now, I would be using adb and termux, then install the termux desktop.