lørdag 21. desember 2013

Nodejs and Express on OpenShift

It's real easy to get the basic Node.js-server up. Simply create a free account and verify it. Then create new app, choose Node.js, and fill in a short form. And it's live.

They even provide the commands to copy for you to clone the git repo, to push changes and to log in via ssh.

I threw in a Nodejs cartridge (which are their click and deploy units) and had a look. I should probably have started with a framework that I have a better understanding of, but hey! You fire, you miss, you get over it and reload :)

Express locally. OpenShift has the Express module installed globally (for all users), which I didn't have locally. To see all the packages with version numbers that's installed on the server, I ssh-ed in and execute "npm list -g" and found the version number. Then I just installed Express locally by doing "sudo npm remove -g express@2.5.8".  Then I added the Githubs recommended content for the .gitignore file for a Nodejs project, so I won't push that to the server.

After that, I stared at the server.js more confused than not. Express is inspired by Sintra, they're bot web application frameworks. I guess the idea is to make it easier to create webapps. Basically you capture the request URL and the method (get/post), and define how to respond to that.

Etiketter: ,

0 Kommentarer:

Legg inn en kommentar

Abonner på Legg inn kommentarer [Atom]

<< Startsiden