Skip to content

Commit

Permalink
Change settings for Heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
wkh237 committed Oct 30, 2016
1 parent 4e64375 commit 4ed0fd7
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 14 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node index.js
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# node-js-getting-started

A barebones Node.js app using [Express 4](http://expressjs.com/).

This application supports the [Getting Started with Node on Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs) article - check it out.

## Running Locally

Make sure you have [Node.js](http://nodejs.org/) and the [Heroku Toolbelt](https://toolbelt.heroku.com/) installed.

```sh
$ git clone [email protected]:heroku/node-js-getting-started.git # or clone your own fork
$ cd node-js-getting-started
$ npm install
$ npm start
```

Your app should now be running on [localhost:5000](http://localhost:5000/).

## Deploying to Heroku

```
$ heroku create
$ git push heroku master
$ heroku open
```
or

[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)

## Documentation

For more information about using Node.js on Heroku, see these Dev Center articles:

- [Getting Started with Node.js on Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs)
- [Heroku Node.js Support](https://devcenter.heroku.com/articles/nodejs-support)
- [Node.js on Heroku](https://devcenter.heroku.com/categories/nodejs)
- [Best Practices for Node.js Development](https://devcenter.heroku.com/articles/node-best-practices)
- [Using WebSockets on Heroku with Node.js](https://devcenter.heroku.com/articles/node-websockets)
8 changes: 8 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Start on Heroku: Node.js",
"description": "A barebones Node.js app using Express 4",
"repository": "https://github.com/heroku/node-js-getting-started",
"logo": "http://node-js-sample.herokuapp.com/node.svg",
"keywords": ["node", "express", "static"],
"image": "heroku/nodejs"
}
14 changes: 6 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var Canvas = require('canvas');
var express = require('express');
var Canvas = require('canvas');
var Image = Canvas.Image;
var fs = require('fs');

var PORT = 19999;
var app = express();

app.set('port', (process.env.PORT || 5000));

app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});

app.get('/tiles/:z/:x/:y', function (req, res) {
var x = req.params.x,
Expand All @@ -15,10 +17,6 @@ app.get('/tiles/:z/:x/:y', function (req, res) {
res.type('image/png').send(generateTile(x,y,z));
});

app.listen(PORT, function () {
console.log('Tile server is listening on port ' + PORT);
});

function generateTile(x,y,z) {

var canvas = new Canvas(256, 256);
Expand Down
29 changes: 23 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
{
"name": "Dummy-map-tiles",
"name": "dummy-tiles-sever",
"version": "0.0.1",
"private": true,
"Dependencies": {
"canvas": "^1.6.1",
"express": "^4.14.0"
}
"description": "A node server generates dummy map tiles",
"engines": {
"node": "5.9.1"
},
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "4.13.3",
"canvas": "^1.6.1"
},
"repository": {
"type": "git",
"url": "https://github.com/heroku/node-js-getting-started"
},
"keywords": [
"node",
"heroku",
"express"
],
"license": "MIT"
}
23 changes: 23 additions & 0 deletions views/pages/db.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<% include ../partials/header.ejs %>
</head>

<body>

<% include ../partials/nav.ejs %>

<div class="container">
<h2>Database Results</h2>

<ul>
<% results.forEach(function(r) { %>
<li><%= r.id %> - <%= r.name %></li>
<% }); %>
</ul>

</div>

</body>
</html>
66 changes: 66 additions & 0 deletions views/pages/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<% include ../partials/header.ejs %>
</head>

<body>

<% include ../partials/nav.ejs %>

<div class="jumbotron text-center">
<div class="container">
<a href="/" class="lang-logo">
<img src="/lang-logo.png">
</a>
<h1>Getting Started with Node on Heroku</h1>
<p>This is a sample Node application deployed to Heroku. It's a reasonably simple app - but a good foundation for understanding how to get the most out of the Heroku platform.</p>
<a type="button" class="btn btn-lg btn-default" href="https://devcenter.heroku.com/articles/getting-started-with-nodejs"><span class="glyphicon glyphicon-flash"></span> Getting Started with Node</a>
<a type="button" class="btn btn-lg btn-primary" href="https://github.com/heroku/node-js-getting-started"><span class="glyphicon glyphicon-download"></span> Source on GitHub</a>
</div>
</div>
<div class="container">
<div class="alert alert-info text-center" role="alert">
To deploy your own copy, and learn the fundamentals of the Heroku platform, head over to the <a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs" class="alert-link">Getting Started with Node on Heroku</a> tutorial.
</div>
<hr>
<div class="row">
<div class="col-md-6">
<h3><span class="glyphicon glyphicon-info-sign"></span> How this sample app works</h3>
<ul>
<li>This app was deployed to Heroku, either using Git or by using <a href="https://github.com/heroku/node-js-getting-started">Heroku Button</a> on the repository.</li>

<li>When Heroku received the source code, it fetched all the dependencies in the <a href="https://github.com/heroku/node-js-getting-started/blob/master/package.json">package.json</a>, creating a deployable slug.</li>
<li>The platform then spins up a dyno, a lightweight container that provides an isolated environment in which the slug can be mounted and executed.</li>
<li>You can scale your app, manage it, and deploy over <a href="https://addons.heroku.com/">150 add-on services</a>, from the Dashboard or CLI.</li>
</ul>
</div>
<div class="col-md-6">
<h3><span class="glyphicon glyphicon-link"></span> Next Steps</h3>
<ul>
<li>If you are following the <a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs">Getting Started</a> guide, then please head back to the tutorial and follow the next steps!</li>
<li>If you deployed this app by deploying the Heroku Button, then in a command line shell, run:</li>
<ul>
<li><code>git clone https://github.com/heroku/node-js-getting-started.git</code> - this will create a local copy of the source code for the app</li>
<li><code>cd node-js-getting-started</code> - change directory into the local source code repository</li>
<li><code>heroku git:remote -a &lt;your-app-name></code> - associate the Heroku app with the repository</li>
<li>You'll now be set up to run the app locally, or <a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs#push-local-changes">deploy changes</a> to Heroku</li>
</ul>
</ul>
<h3><span class="glyphicon glyphicon-link"></span> Helpful Links</h3>
<ul>
<li><a href="https://www.heroku.com/home">Heroku</a></li>
<li><a href="https://devcenter.heroku.com/">Heroku Dev Center</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs">Getting Started with Node on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/deploying-nodejs">Deploying Node Apps on Heroku</a></li>
</ul>
</div>
</div> <!-- row -->
<div class="alert alert-info text-center" role="alert">
Please do work through the Getting Started guide, even if you do know how to build such an application. The guide covers the basics of working with Heroku, and will familiarize you with all the concepts you need in order to build and deploy your own apps.
</div>
</div>


</body>
</html>
5 changes: 5 additions & 0 deletions views/partials/header.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<title>Node.js Getting Started on Heroku</title>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="/stylesheets/main.css" />
33 changes: 33 additions & 0 deletions views/partials/nav.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<nav class="navbar navbar-default navbar-static-top navbar-inverse">
<div class="container">
<ul class="nav navbar-nav">
<li class="active">
<a href="/"><span class="glyphicon glyphicon-home"></span> Home</a>
</li>
<li>
<a href="https://devcenter.heroku.com/articles/how-heroku-works"><span class="glyphicon glyphicon-user"></span> How Heroku Works</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="glyphicon glyphicon-info-sign"></span> Getting Started Guides <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-ruby">Getting Started with Ruby on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-nodejs">Getting Started with Node on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-php">Getting Started with PHP on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-python">Getting Started with Python on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-java">Getting Started with Java on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-go">Getting Started with Go on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-clojure">Getting Started with Clojure on Heroku</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-scala">Getting Started with Scala on Heroku</a></li>
<li class="divider"></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-heroku-and-connect-without-local-dev">Getting Started on Heroku with Heroku Connect</a></li>
<li><a href="https://devcenter.heroku.com/articles/getting-started-with-jruby">Getting Started with Ruby on Heroku (Microsoft Windows)</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="navbar-right">
<a href="https://devcenter.heroku.com"><span class="glyphicon glyphicon-book"></span> Heroku Dev Center</a>
</li>
</ul>
</div>
</nav>

0 comments on commit 4ed0fd7

Please sign in to comment.