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 %> + +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 +git clone https://github.com/heroku/node-js-getting-started.git
- this will create a local copy of the source code for the appcd node-js-getting-started
- change directory into the local source code repositoryheroku git:remote -a <your-app-name>
- associate the Heroku app with the repository