From f2720e8997bfeef15c23cba2c70270271c10cd51 Mon Sep 17 00:00:00 2001 From: Cory House Date: Sun, 23 Oct 2016 10:18:17 -0500 Subject: [PATCH] Move all to root for simplicity --- Procfile | 2 +- dist/app.json => app.json | 2 +- dist/index.js => index.js | 11 ++++++++--- package.json | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) rename dist/app.json => app.json (75%) rename dist/index.js => index.js (80%) diff --git a/Procfile b/Procfile index f474a4e..1da0cd6 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: node dist/index.js +web: node index.js diff --git a/dist/app.json b/app.json similarity index 75% rename from dist/app.json rename to app.json index 5dc6a6a..2d8a7d1 100644 --- a/dist/app.json +++ b/app.json @@ -1,7 +1,7 @@ { "name": "Node API example", "description": "A simple API built in Node and Express hosted on Heroku", - "repository": "https://github.com/heroku/node-js-sample", + "repository": "https://github.com/coryhouse/js-dev-env-demo-api", "logo": "http://node-js-sample.herokuapp.com/node.svg", "keywords": ["node", "express", "static"] } diff --git a/dist/index.js b/index.js similarity index 80% rename from dist/index.js rename to index.js index eefdcc1..85bdbd0 100644 --- a/dist/index.js +++ b/index.js @@ -1,9 +1,14 @@ -var express = require('express'); -var app = express(); +import express from 'express'; + +const app = express(); app.set('port', (process.env.PORT || 5000)); app.use(express.static(__dirname + '/public')); +app.get('/', function(request, response) { + response.send('Hello World!') +}); + app.get('/users', function(req, res) { // Hard coding for simplicity. Pretend this hits a real database res.json([ @@ -14,5 +19,5 @@ app.get('/users', function(req, res) { }); app.listen(app.get('port'), function() { - console.log("Node app is running at localhost:" + app.get('port')); + console.log("Node app is running at localhost:" + app.get('port')); }); \ No newline at end of file diff --git a/package.json b/package.json index bf7bfe9..321ae61 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A simple API built in Node and Express hosted on Heroku", "main": "index.js", "scripts": { - "start": "node dist/index.js" + "start": "node index.js" }, "dependencies": { "express": "4.13.3"