From f703c33b739c196536fb02660765feab7762a469 Mon Sep 17 00:00:00 2001 From: VuthyVey Date: Fri, 9 Dec 2016 14:53:13 +0700 Subject: [PATCH] add default files --- Procfile | 1 + app.json | 8 +++++ index.js | 52 ++++++++++++++++++++++++++++ package.json | 33 ++++++++++++++++++ public/lang-logo.png | Bin 0 -> 2293 bytes public/node.svg | 17 ++++++++++ public/stylesheets/main.css | 27 +++++++++++++++ views/pages/db.ejs | 23 +++++++++++++ views/pages/index.ejs | 66 ++++++++++++++++++++++++++++++++++++ views/pages/vuthy.ejs | 14 ++++++++ views/partials/header.ejs | 5 +++ views/partials/nav.ejs | 33 ++++++++++++++++++ 12 files changed, 279 insertions(+) create mode 100644 Procfile create mode 100644 app.json create mode 100644 index.js create mode 100644 package.json create mode 100644 public/lang-logo.png create mode 100644 public/node.svg create mode 100644 public/stylesheets/main.css create mode 100644 views/pages/db.ejs create mode 100644 views/pages/index.ejs create mode 100644 views/pages/vuthy.ejs create mode 100644 views/partials/header.ejs create mode 100644 views/partials/nav.ejs 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 0000000000000000000000000000000000000000..e8a2e8b0f7aa3126f56dbb8c3514a11b64023a18 GIT binary patch literal 2293 zcmb8x`6CmI1IO`|Yt1=wWRAvM$wL{-v1p@_BWDTWt2vealyf5iTOK*2vBHl5@0 zheHug7!;tkPhk!K0Me~3&biSx+JX1=-BA!zO8Q;u^s(1N;#mfh&vI}e}}UC zmbW+cy)nRS_RbRWThsSUs6UOQ)t7e%jx z<{vtBCyNwQSihv>s$nr9w?xXxe6OTFl&hnL(uWH=ns6ky6t6SNsB3 zmu7_Rua>v*`qt)L-@0-jm)=$Nru7H9{8bzV>Q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_mc^#)T<5?a{z+_aIX`k5Qx$w~AC*0gSbHTYk z_Bhu4=Dcq93(Npbhxd#v?e!yRtqNP&tIzwbu}lRKooMktsh{=a%Z)fkk_+T(q#qh< zVxRsf;}=joyqo|!$!qFfRw87NA0-Si(Pa+-YKq%?R@t^1PHPZxclFL-=%G$TLLlLC zeByPtA&FH37yUin^W2sKIYL_eb#%p9t@&PRi;5qr+++%dm&rZnOYB4n{dIQ$O!)W_ zrkwL+Q+c}%ij|fdmsk2jM>*m_eq&Lom|1d;ynxZQw^y}_%Won&=NJHA(-_|m#nn) z_#cxMUt=$i09X1sN=7>wBQ)0UdRSI{*x1 W{LbprEX)4WF#u~zdy86>PyE0AE>_wA literal 0 HcmV?d00001 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 %> + +
+

Database Results

+ +
    + <% results.forEach(function(r) { %> +
  • <%= r.id %> - <%= r.name %>
  • + <% }); %> +
+ +
+ + + 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/pages/vuthy.ejs b/views/pages/vuthy.ejs new file mode 100644 index 0000000..35c68f7 --- /dev/null +++ b/views/pages/vuthy.ejs @@ -0,0 +1,14 @@ + + + + <% include ../partials/header.ejs %> + + + + +<% include ../partials/nav.ejs %> + +

Hi! My name is Vuthy

+ + + 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 @@ +