Codementor Events

A Taste of Node Express

Published Apr 12, 2019Last updated Oct 08, 2019

A Taste of Node Express

I am helping a student debug #code in a #node framework I've never even heard of until today #programming #coding #dev #webdev #devcommunity

After having bruteforced my way through Python's Flask, I now have a pretty good gist of what it means to create a REST setup.

Basically, the tl;dr of it is that modern websites do things in the following way:

www.somesite.com/myrest/login
www.somesite.com/myrest/logout
www.somesite.com/myrest/getuserinfo
www.somesite.com/myrest/dostuff
www.somesite.com/myrest/post
www.somesite.com/myrest/etc

Note the very nice structuring here. This is done on purpose for organization. I was totally not used to this growing up. Nobody taught me REST. Nobody taught me how to do anything like this in webdev. I didn't even wanna do webdev originally...

This journey all began around age 11 or 12. Not long after my back surgery, our home got Internet via America Online 3.0. I began making websites shortly after. Before this, a family friend gave me my first machine: an MSDOS Tandy machine. I remember figuring out how to write a simple 4-function calculator in BASIC back then. My websites were written in simple HTML, but even then, I managed to get onto a Final Fantasy 7 webring (lol, the good old days).

Recently, I helped a student find some bugs in a language thingy I barely know anything about, but it turns out that if you know some basic things that you can cross-apply them to areas that you don't know.

This is, in general, how people pick up new things.

node express seems like something similar to Flask, but for node (duh). It is a REST-type system that allows you to construct endpoints in a similar manner. Like Flask, you can test it locally or run it on a server. This makes it super-easy to whip-up custom websites.

A lot of what I see from my student's code looks like this:

app.get('/home', function(req, res) {
  // code here
});

app.post('/login', function(req, res) {
  // code here	
});

It is pretty cool. Javascript is easy (which is why I've never used it lol), but as I am growing up, I am finding that you can do some really cool stuff with it super-easily.

I've always preferred working from a lower-level or backend perspective, but everyone's always trying to pick me up for iOS or webdev frontend roles (ugh!), and for a long time, node.js just seemed too hipster (like Ruby) for me to care about.

After this student, I'm gonna have a sit-down with node.js. In a world of Angulars and Reacts and vues, I'm thinking I'm a node 😄
ing here...

Discover and read more posts from Mike Bell
get started
post commentsBe the first to share your opinion
Kamlesh Singh Bisht
5 years ago

I am very new to typescript with node js, express, and MongoDB, I need an end to end flow to please anyone can you suggest me or any links/Anyone give me step by step.

How to compile/run this application?

How to deploy this type of application?

Thanks & Regards
solve email problems

Ricardo Ferreira da Silva
5 years ago

In order to run a node script tipically you would just call “node index.js”, for example. Regarding deployment there are many options. You can try to dockerize your node project and implement continuous integration, that would be a fun project.

Jellene Khoh
5 years ago

Hehehe, it’s a gateway drug!

You might also want to try typescript with node.js. Typescript gives you interfaces, which is good for database models. Simplest way is to use ts-node to serve the typescript files. https://github.com/TypeStrong/ts-node

Show more replies