diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..1da0cd6 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node index.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..e37a79c --- /dev/null +++ b/README.md @@ -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 git@github.com: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) diff --git a/app.json b/app.json new file mode 100644 index 0000000..58ca7e2 --- /dev/null +++ b/app.json @@ -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" +} diff --git a/index.js b/index.js index aae6f0f..2c73a98 100644 --- a/index.js +++ b/index.js @@ -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, @@ -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); diff --git a/package.json b/package.json index 65966f0..e851abb 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/views/pages/db.ejs b/views/pages/db.ejs new file mode 100644 index 0000000..27a5f49 --- /dev/null +++ b/views/pages/db.ejs @@ -0,0 +1,23 @@ + + + + <% include ../partials/header.ejs %> + + + + +<% include ../partials/nav.ejs %> + +
+

Database Results

+ + + +
+ + + diff --git a/views/pages/index.ejs b/views/pages/index.ejs new file mode 100644 index 0000000..4c39473 --- /dev/null +++ b/views/pages/index.ejs @@ -0,0 +1,66 @@ + + + + <% include ../partials/header.ejs %> + + + + + <% include ../partials/nav.ejs %> + +
+
+ +

Getting Started with Node on Heroku

+

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.

+ Getting Started with Node + Source on GitHub +
+
+
+ +
+
+
+

How this sample app works

+
    +
  • This app was deployed to Heroku, either using Git or by using Heroku Button on the repository.
  • + +
  • When Heroku received the source code, it fetched all the dependencies in the package.json, creating a deployable slug.
  • +
  • The platform then spins up a dyno, a lightweight container that provides an isolated environment in which the slug can be mounted and executed.
  • +
  • You can scale your app, manage it, and deploy over 150 add-on services, from the Dashboard or CLI.
  • +
+
+
+

Next Steps

+
    +
  • If you are following the Getting Started guide, then please head back to the tutorial and follow the next steps!
  • +
  • If you deployed this app by deploying the Heroku Button, then in a command line shell, run:
  • +
      +
    • git clone https://github.com/heroku/node-js-getting-started.git - this will create a local copy of the source code for the app
    • +
    • cd node-js-getting-started - change directory into the local source code repository
    • +
    • heroku git:remote -a <your-app-name> - associate the Heroku app with the repository
    • +
    • You'll now be set up to run the app locally, or deploy changes to Heroku
    • +
    +
+

Helpful Links

+ +
+
+ +
+ + + + diff --git a/views/partials/header.ejs b/views/partials/header.ejs new file mode 100644 index 0000000..bd0069f --- /dev/null +++ b/views/partials/header.ejs @@ -0,0 +1,5 @@ +Node.js Getting Started on Heroku + + + + diff --git a/views/partials/nav.ejs b/views/partials/nav.ejs new file mode 100644 index 0000000..224b5e7 --- /dev/null +++ b/views/partials/nav.ejs @@ -0,0 +1,33 @@ +