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/app.json b/app.json new file mode 100644 index 0000000..d016e36 --- /dev/null +++ b/app.json @@ -0,0 +1,8 @@ +{ + "name": "Liger Pedro", + "description": "A currency at Liger", + "repository": "https://github.com/VuthyVey/ligerpedro", + "logo": "http://node-js-sample.herokuapp.com/node.svg", + "keywords": ["node", "express", "static"], + "image": "heroku/nodejs" +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..2eea4f3 --- /dev/null +++ b/index.js @@ -0,0 +1,52 @@ +var cool = require('cool-ascii-faces'); +var express = require('express'); +var app = express(); + +app.set('port', (process.env.PORT || 5000)); + +app.use(express.static(__dirname + '/public')); + +// views is directory for all template files +app.set('views', __dirname + '/views'); +app.set('view engine', 'ejs'); + +app.get('/', function(request, response) { + response.render('pages/index'); +}); + +app.get('/cool', function(request, response) { + response.send(cool()); +}); + +app.get('/times', function(request, response) { + var result = '' + var times = process.env.TIMES || 5 + for (i=0; i < times; i++) + result += i + ' '; + response.send(result); +}); + + +app.get('/vuthy', function(request, response) { + response.render('pages/vuthy'); +}); + +var pg = require('pg'); + +app.get('/db', function (request, response) { + pg.connect(process.env.DATABASE_URL, function(err, client, done) { + client.query('SELECT * FROM test_table', function(err, result) { + done(); + if (err) + { console.error(err); response.send("Error " + err); } + else + { response.render('pages/db', {results: result.rows} ); } + }); + }); +}); + +app.listen(app.get('port'), function() { + console.log('Hi! Vuthy!'); + console.log('Node app is running on port', app.get('port')); +}); + diff --git a/package.json b/package.json new file mode 100644 index 0000000..f44998e --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "node-js-getting-started", + "version": "0.2.5", + "description": "A sample Node.js app using Express 4", + "engines": { + "node": "5.9.1" + }, + "main": "index.js", + "scripts": { + "start": "node index.js" + }, + "dependencies": { + "cool-ascii-faces": "1.3.3", + "ejs": "2.3.3", + "express": "4.13.3", + "pg": "4.5.6" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/VuthyVey/ligerpedro.git" + }, + "keywords": [ + "node", + "heroku", + "express" + ], + "license": "Liger Learning Center", + "bugs": { + "url": "" + }, + "homepage": "https://github.com/VuthyVey/ligerpedro#readme", + "author": "Liger Students" +} diff --git a/public/lang-logo.png b/public/lang-logo.png new file mode 100644 index 0000000..e8a2e8b Binary files /dev/null and b/public/lang-logo.png differ diff --git a/public/node.svg b/public/node.svg new file mode 100644 index 0000000..3c7e161 --- /dev/null +++ b/public/node.svg @@ -0,0 +1,17 @@ + + + + diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css new file mode 100644 index 0000000..2d1ee1b --- /dev/null +++ b/public/stylesheets/main.css @@ -0,0 +1,27 @@ +.jumbotron { + background: #532F8C; + color: white; + padding-bottom: 80px; } + .jumbotron .btn-primary { + background: #845ac7; + border-color: #845ac7; } + .jumbotron .btn-primary:hover { + background: #7646c1; } + .jumbotron p { + color: #d9ccee; + max-width: 75%; + margin: 1em auto 2em; } + .navbar + .jumbotron { + margin-top: -20px; } + .jumbotron .lang-logo { + display: block; + background: #B01302; + border-radius: 50%; + overflow: hidden; + width: 100px; + height: 100px; + margin: auto; + border: 2px solid white; } + .jumbotron .lang-logo img { + max-width: 100%; } + 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