3

Building My First Node App

 1 year ago
source link: https://fuzzyblog.io/blog/node/2019/06/05/building-my-first-node-app.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Building My First Node App

Jun 5, 2019

As anyone who reads this blog knows, I am a Ruby / Rails guy. Yes I flirt with other things from time to but but, at heart, I am a ruby guy and specifically of the Rails flavor. Part of the reason for that is that I adore the set of choices that Rails as a whole makes for me. I look at other communities, say Python or Node, and I always think "Man do I really want to figure out a collection of libraries for Task X, Task Y and Task Z and then figure out if they work together?". I adore that Rails has put together a set of defaults that just plain work together.

Now, that said, sometimes you do have to go farther afield than Rails and this week I found myself needing to put together a basic Node app for one of my students to run with.

Problem Description

What I need to build is effectively a two page web site - a form which a nodejs backend which calls an API and then generates a page of results for the user. It is effectively a specialized travel calculator. This isn't very much but when you don't really know anything about a platform, even the tiniest thing can be problematic.

Things I Read

Here are the articles I looked at:

  • [Hackathon Starter][https://github.com/sahat/hackathon-starter]
  • AirPair NodeJS Tutorial
  • [Building A Simple NodeJS API] (https://medium.freecodecamp.org/building-a-simple-node-js-api-in-under-30-minutes-a07ea9e390d2)

A Starting Point

The best starting point I found was hackathon-starter. It is absolutely more than necessary and needs to be cut back but what I got with this was:

  • a modern looking starter app
  • done in an MVC style fashion
  • complete with CSS that doesn't suck

Useful Commands

These were useful commands:

To create a bare bones, basic Node app:

npm init

To install the nodemon package which lets changes be reloaded dynamically without restarting the app server:

npm install nodemon -g

Stack Overflow on Installing Nodemon

To run the app via nodemon:

nodemon app.js

And that's about all I have time for right now but it is a real start on the process. The next step is to write the application specific code.


Posted In: #node #javascrpt


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK