Skip to content

Commit 3455225

Browse files
committed
tms
2 parents ae680ba + 7f76abd commit 3455225

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+25570
-0
lines changed

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
lib-cov
2+
*.seed
3+
*.log
4+
*.csv
5+
*.dat
6+
*.out
7+
*.pid
8+
*.gz
9+
10+
pids
11+
logs
12+
results
13+
14+
npm-debug.log
15+
16+
node_modules
17+
*~
18+
19+
data
20+
21+
test/mine.options.js
22+
test/data
23+
24+
.build
25+
26+
old/*
27+
bower_components/*
28+
29+
30+
docker/stage/app

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sudo: required
2+
dist: trusty
3+
language: node_js
4+
5+
6+
node_js:
7+
- '4'
8+
- '6'
9+
- '8'
10+
11+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014-2017 Richard Rodger and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# The nodezoo microservice demonstration architecture
2+
3+
This is a repository in the microservice demonstration system for
4+
the [Tao of Microservices](//bit.ly/rmtaomicro) book (chapter 9). This
5+
code is live at [nodezoo.com](//nodezoo.com).
6+
7+
This system shows you how to construct a full microservice
8+
architecture. It is MIT licensed so that you can cut-and-paste to
9+
build your own system with minimal effort. The system consists of
10+
multiple repositories, and runs ten or so microservices in production
11+
([Kubernetes](//kubernetes.io)), staging ([Docker](//docker.com)), and
12+
development ([fuge](//github.com/apparatus/fuge)) modes.
13+
14+
The best place to get started is
15+
the [nodezoo/tao](//github.com/nodezoo/tao) repository, which links to
16+
everything else, and has the _Getting Started_ guide.
17+
18+
## nodezoo-web
19+
20+
_TODO_
21+
22+

docker/stage/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
FROM nodezoo-shared:1
3+
4+
ADD app /app/
5+
6+
CMD ["node", "/app/srv/web-stage.js"]
7+
8+
9+
10+
11+

docker/stage/Dockerfile-prod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
FROM nodezoo-web:1
3+
4+
CMD ["node", "/app/srv/web-prod.js"]
5+
6+
7+
8+
9+

docker/stage/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
build :
2+
mkdir -p app
3+
cp -r ../../web.js ../../srv ../../www app
4+
docker build -t nodezoo-web:1 .
5+
docker build -t nodezoo-web-prod:1 -f Dockerfile-prod .
6+
7+
clean :
8+
rm *~
9+
10+
.PHONY : build clean

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "nodezoo-web",
3+
"version": "1.0.0",
4+
"description": "nodezoo-web",
5+
"main": "web.js",
6+
"keywords": [
7+
"nodezoo",
8+
"seneca",
9+
"web",
10+
"microservice"
11+
],
12+
"scripts": {
13+
"test": "lab -P test",
14+
"mock": "MOCK_SEARCH=true MOCK_INFO=true MOCK_SUGGEST=true node srv/web-dev.js"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/nodezoo/nodezoo-web.git"
19+
},
20+
"author": "Richard Rodger (http://richardrodger.com)",
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/nodezoo/nodezoo-web/issues"
24+
},
25+
"homepage": "https://github.com/nodezoo/nodezoo-web",
26+
"dependencies": {
27+
"handlebars": "4.0.6",
28+
"hapi": "16.1.0",
29+
"inert": "4.1.0",
30+
"seneca": "3.4.2",
31+
"seneca-balance-client": "0.6.1",
32+
"seneca-monitor": "0.1.0",
33+
"seneca-entity": "2.0.2",
34+
"seneca-mesh": "0.11.0",
35+
"seneca-repl": "1.1.2",
36+
"vision": "4.1.1"
37+
},
38+
"devDependencies": {
39+
"code": "4.1.x",
40+
"lab": "14.0.x",
41+
"wreck": "10.0.x"
42+
}
43+
}

srv/web-dev-mesh.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright (c) 2014-2017 Richard Rodger and other contributors, MIT License */
2+
3+
var Seneca = require('seneca')
4+
5+
6+
// Build the frontend server using the hapi framework.
7+
var app = require('../web.js')
8+
9+
10+
Seneca({tag: 'web'})
11+
//.test()
12+
.test('print')
13+
.use('monitor')
14+
15+
.use('mesh')
16+
17+
.use('seneca-repl', {port:10010})
18+
19+
.ready(function(){
20+
var server = app({seneca: this})
21+
22+
this.log.info(server.info)
23+
})

srv/web-dev.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* Copyright (c) 2014-2017 Richard Rodger and other contributors, MIT License */
2+
3+
var MOCK_SEARCH = JSON.parse(process.env.MOCK_SEARCH || 'false')
4+
var MOCK_INFO = JSON.parse(process.env.MOCK_INFO || 'false')
5+
var MOCK_SUGGEST = JSON.parse(process.env.MOCK_SUGGEST || 'false')
6+
var MOCK = MOCK_SEARCH || MOCK_INFO || MOCK_SUGGEST
7+
8+
9+
var Seneca = require('seneca')
10+
11+
12+
// Build the frontend server using the hapi framework.
13+
var app = require('../web.js')
14+
15+
16+
Seneca({tag: 'web'})
17+
.test('print')
18+
19+
.use('seneca-repl', {port:10010})
20+
21+
.listen(9010)
22+
23+
// Use port numbers for local development.
24+
.client({pin:'role:search', port:9020})
25+
.client({pin:'role:info', port:9030})
26+
.client({pin:'role:suggest', port:9060})
27+
28+
.ready(function(){
29+
var server = app({seneca: this})
30+
31+
this.log.info(server.info)
32+
})
33+
34+
35+
// Run mock services that this service depends on.
36+
if (MOCK) {
37+
var mock = Seneca({tag:'mock'})
38+
.test('print')
39+
40+
if (MOCK_SEARCH) {
41+
mock
42+
.listen(9020)
43+
.add('role:search', function (msg, reply) {
44+
reply({
45+
46+
// Create fake results using each term of the query.
47+
items: msg.query.split(/\s+/).map(function (term) {
48+
return {name:term, version:'1.0.0', desc:term+'!'}
49+
})
50+
})
51+
})
52+
}
53+
54+
if (MOCK_INFO) {
55+
mock
56+
.listen(9030)
57+
.add('role:info', function (msg, reply) {
58+
reply({npm:{name:msg.name, version:'1.0.0'}})
59+
})
60+
}
61+
62+
if (MOCK_SUGGEST) {
63+
mock
64+
.listen(9060)
65+
.add('role:suggest', function (msg, reply) {
66+
reply(msg.query.split(''))
67+
})
68+
}
69+
}

0 commit comments

Comments
 (0)