now - realtime node.js deployments
Now allows you deploy nodejs applications in realtime, from your terminal. Think of this as a simpler Heroku for nodejs. You simply run now
in your project directory and you get a unique URL similar to this: https://yo-smppqrgsbt.now.sh
Installation
My fav thing about this is how easy it is setup and use. You only need to install the node module globally (the g flag).
Usage
To deploy, just run now
in your project directory. I will create a simple project as an example.
Our project directory needs to have the package.json file so we need to initialize one.
This prompts some questions to generate the package.json
file. I basically just go with the default. (Just press enter all through). Here is what I get for my package.json
But one more thing - the file needs a start
command so we add one.
Now that we have the package.json
file, let’s create a simple experiment. Here is where I create a simple code that prints ‘Hello world’ but let’s do something more interesting. Let’s create a simple API experiment. (I love APIs). Let’s get the BBC Radio 1’s playlist and display it. The API endpoint is http://www.bbc.co.uk/radio1/playlist.json
and it requires no authentication. We just send a GET
request to it and format the JSON response.
I will need express module for routing and request module for HTTP request, so let’s install them.
(–save adds the modules to our package.json file)
Now our index.js
code
(Ideally, you should use a template engine for the html. I am using es6 template literals here to keep things simple.)
Now that we have our code, all we need to do to deploy is to type now
in the project directory in our terminal.
If it’s your first time, now
requests for your email and sends you a verification link. Once deployed, your deployment url is returned. Here is mine https://radio-one-yufyrttcin.now.sh. You can see the source here https://radio-one-yufyrttcin.now.sh/_src/?f=index.js (Just add _src
after the URL)
Takeaways
Note: a lot of things I will mention will probably be due to the fact that it’s a really new project. I mean, the latest version is 0.10.0. However, here are my takeaways:
Ports
I love how you can listen on any port. As you can see from my source, I used :3000 but the deployment is available on 80 on https://radio-one-yufyrttcin.now.sh/
Deploy counts and Pricing
The free plan comes with 20 monthly deploys among other limitations like bandwidth, storage and filesize. I don’t think deployments should count as a limiting factor. It’s easy to blow 20 deploys on a single project in under an hour.
now
generates a unique URL for every new deployment. This means if you update a single character, it is treated as a new one and you get a new URL. (The old one will still work by the way). I should be able to consolidate my deployments to a single URL. Or/and delete ones I no longer need. (Update: From 0.11.0 you can delete deployments with now -rm
Still on pricing, there is no details about upgrading to the premium plan. (Update 2: You can now login to your account online, add your billing details and upgrade). I was also expecting to see custom domains somewhere there.
DB hosting
Nothing on database hosting yet. Well for me this is not a biggie. You can always host your database somewhere else and just use the db url. For mongodb, mLab for example has a free 500MB sandbox plan.
In conclusion, if you want to run quick experiments or need quick webhooks for that bot, you can use now
. It’s simple and cool. This is one project I am closely following.