Skip to content

Commit b3ba8e6

Browse files
authored
Merge pull request #7 from wercker/update-code-and-readme-for-oow
Update code and readme for oow
2 parents 0432217 + 76d249d commit b3ba8e6

File tree

5 files changed

+61
-23
lines changed

5 files changed

+61
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.wercker
22
node_modules
3+
package-lock.json

README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
11
# getting-started-nodejs
22

3-
Node.js sample application for wercker built with Express
3+
[![wercker status](https://app.wercker.com/status/7b1a402dd00d57fc9abddf9eb5161675/s "wercker status")](https://app.wercker.com/project/bykey/7b1a402dd00d57fc9abddf9eb5161675)
44

5-
Uses the default Node.js [Docker container](https://registry.hub.docker.com/u/library/node/) from the Docker Hub.
5+
A sample application in Javascript on NodeJS for Wercker.
66

7-
Note: this sample application only runs on the Ewok stack on wercker
7+
This application uses the `node` container obtained from the [Docker Hub](https://hub.docker.com/_/node/)
88

9-
[![wercker status](https://app.wercker.com/status/7b1a402dd00d57fc9abddf9eb5161675/s "wercker status")](https://app.wercker.com/project/bykey/7b1a402dd00d57fc9abddf9eb5161675)
9+
## Setup
10+
Clone this repo and cd into the directory:
11+
12+
```
13+
git clone https://github.com/wercker/getting-started-nodejs.git
14+
cd getting-started-nodejs
15+
```
16+
17+
## Running
18+
You can run the sample app in a couple of different ways. The first is to simply launch the executable:
19+
```
20+
node app.js
21+
```
22+
23+
Now point your browser at `http://localhost:8080` to see:
24+
```
25+
{"cities":["San Francisco","Amsterdam","Berlin","New York","Tokyo"]}
26+
```
27+
28+
The second, and more useful, way is to use the `wercker dev` command to launch the binary within a Docker container, using the base image defined in the `box/id` property at the top of the `wercker.yml`, like so:
29+
```
30+
wercker dev --expose-ports
31+
```
32+
The `dev` target inside `wercker.yml` uses the `internal/watch` step to dynamically reload the runtime container when sourcefile changes are detected, which allows you to quickly test changes without having to kill/rebuild/relaunch the container. For instance, add another city to the array on `app.js:6' like so:
33+
34+
```
35+
res.write(JSON.stringify({"cities" : ["San Francisco", "Amsterdam", "Berlin", "New York", "Tokyo", "London"]}));
36+
```
37+
38+
and then refresh your browser pointing to `http://localhost:8080` to see:
39+
```
40+
{"cities":["San Francisco","Amsterdam","Berlin","New York","Tokyo","London"]}}
41+
```
1042

1143
---
12-
Sign up for wercker [here](http://wercker.com)
13-
Learn more on our [dev center](http://devcenter.wercker.com)
44+
Sign up for Wercker: http://www.wercker.com
45+
46+
Learn more at: http://devcenter.wercker.com

app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ var app = express();
33

44
app.get('/', function(req, res){
55
res.writeHead(200, { 'Content-Type': 'application/json' });
6-
res.write(JSON.stringify({cities : ["San Francisco","Amsterdam", "Berlin", "New York", "Palo ALto", "San Mateo"]}));
6+
res.write(JSON.stringify({cities : ["San Francisco", "Amsterdam", "Berlin", "New York", "Tokyo"]}));
77
res.end();
88
});
99

10-
var port = process.env.PORT || 5000;
10+
var port = process.env.PORT || 8080;
1111
app.listen(port);
1212

1313
module.exports = app;

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"name": "getting-started-nodejs",
3-
"version": "0.0.1",
4-
"engines" : {
2+
"name": "getting-started-nodejs",
3+
"version": "0.0.1",
4+
"engines": {
55
"node": "0.6.x"
6-
},
7-
"dependencies": {
8-
"express": "3.x",
9-
"nodeunit": "0.7.4",
10-
"supertest" : "0.4.0",
11-
"mocha" : "1.6.0"
12-
},
13-
"scripts": {
14-
"test": "./node_modules/mocha/bin/mocha",
15-
"start": "app.js"
16-
}
6+
},
7+
"dependencies": {
8+
"express": "3.x",
9+
"nodeunit": "0.7.4",
10+
"supertest": "0.4.0",
11+
"mocha": "1.6.0"
12+
},
13+
"scripts": {
14+
"test": "./node_modules/mocha/bin/mocha",
15+
"start": "app.js"
1716
}
17+
}

wercker.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
box: node:4.2.6-slim
1+
box:
2+
id: node:latest
3+
ports:
4+
- "8080"
5+
26
dev:
37
steps:
48
- npm-install

0 commit comments

Comments
 (0)