forked from fortunejs/fortune
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from agco/feature/update-master
Feature/update master
- Loading branch information
Showing
56 changed files
with
11,397 additions
and
5,769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"plugins": ["node"], | ||
"extends": ["eslint:recommended", "plugin:node/recommended"], | ||
"rules": { | ||
"node/exports-style": ["error", "module.exports"], | ||
"semi": 2, | ||
"indent": ["error", 2], | ||
"no-console": 0, | ||
"node/no-unpublished-require": ["error", { | ||
"allowModules": [ | ||
"supertest", | ||
"should", | ||
"chai", | ||
"chai-http", | ||
"agco-event-source-stream", | ||
"before", | ||
"sinon", | ||
"nock", | ||
"request-debug", | ||
"profanity-util" | ||
], | ||
"tryExtensions": [".js", ".json", ".node"] | ||
}] | ||
}, | ||
"globals": { | ||
"describe": true, | ||
"before": true, | ||
"it": true, | ||
"expect": true, | ||
"beforeEach": true, | ||
"afterEach": true, | ||
"supertest": true, | ||
"context": true, | ||
"chai": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,13 @@ | ||
language: node_js | ||
node_js: | ||
- '4.2.0' | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- gcc-4.8 | ||
- g++-4.8 | ||
env: | ||
- CXX=g++-4.8 DEBUG=events-reader MONGODB_URL=mongodb://127.0.0.1:27017/test OPLOG_MONGODB_URL=mongodb://127.0.0.1:27017/local | ||
- '8.4.0' | ||
services: | ||
- docker | ||
before_script: | ||
- mongo --version | ||
- mkdir -p db/test | ||
- mongod --port 27017 --dbpath db/test --replSet rs0 --oplogSize 20 --noprealloc --fork --smallfiles --logpath mongodb.log | ||
- sleep 3 | ||
- mongo admin --eval 'printjson(rs.initiate());' | ||
- sleep 20 | ||
script: ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage | ||
- docker-compose -f docker-compose.test.yml up -d db | ||
- docker-compose -f docker-compose.test.yml up initReplicaset | ||
- docker-compose -f docker-compose.test.yml build test | ||
script: docker-compose -f docker-compose.test.yml run test | ||
deploy: | ||
provider: npm | ||
email: [email protected] | ||
|
@@ -27,4 +17,3 @@ deploy: | |
tags: true | ||
repo: agco/harvesterjs | ||
branch: master | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:8.4.0 | ||
|
||
ENV HOME=/home/app/ | ||
|
||
COPY package.json $HOME/harvesterjs/ | ||
|
||
WORKDIR $HOME/harvesterjs/ | ||
|
||
RUN npm install --progress=false | ||
|
||
COPY . $HOME/harvesterjs/ | ||
|
||
CMD ["npm", "test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "2" | ||
services: | ||
test: | ||
build: . | ||
command: bash -c "sleep 20 && npm test" | ||
depends_on: | ||
- db | ||
environment: | ||
- DEBUG= | ||
- MONGODB_URL=mongodb://db:27017/test | ||
- OPLOG_MONGODB_URL=mongodb://db:27017/local | ||
db: | ||
image: mongo:3.4.0 | ||
command: mongod --replSet rs0 --oplogSize 20 --smallfiles --nojournal | ||
initReplicaset: | ||
image: mongo:3.4.0 | ||
command: bash -c "sleep 10 && mongo admin --host db:27017 --eval 'printjson(rs.initiate());'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,58 @@ | ||
var harvester = require('../lib/harvester'); | ||
'use strict'; | ||
// eslint-disable-next-line | ||
let harvester = require('../lib/harvester'); | ||
|
||
var dockerHostURL = process.env.DOCKER_HOST; | ||
var mongodbHostname; | ||
let dockerHostURL = process.env.DOCKER_HOST; | ||
let mongodbHostname; | ||
// if Mongodb is being run from Docker the DOCKER_HOST env variable should be set | ||
// use this value to derive the hostname for the Mongodb connection params | ||
if (dockerHostURL) { | ||
mongodbHostname = require('url').parse(dockerHostURL).hostname; | ||
mongodbHostname = require('url').parse(dockerHostURL).hostname; | ||
} else { | ||
// fallback if Mongodb is being run from the host machine | ||
mongodbHostname = "127.0.0.1"; | ||
// fallback if Mongodb is being run from the host machine | ||
mongodbHostname = '127.0.0.1'; | ||
} | ||
|
||
var apiPort = process.argv[2] || 1337; | ||
var apiHost = "http://localhost:" + apiPort; | ||
let apiPort = process.argv[2] || 1337; | ||
let apiHost = 'http://localhost:' + apiPort; | ||
|
||
// boot up harvester | ||
harvester({ | ||
adapter: 'mongodb', | ||
connectionString: "mongodb://" + mongodbHostname + ":27017/test", | ||
oplogConnectionString: "mongodb://" + mongodbHostname + ":27017/local" | ||
adapter: 'mongodb', | ||
connectionString: 'mongodb://' + mongodbHostname + ':27017/test', | ||
oplogConnectionString: 'mongodb://' + mongodbHostname + ':27017/local', | ||
}) | ||
.resource('artists', { | ||
name: String | ||
}) | ||
.listen(apiPort); | ||
|
||
.resource('artists', { | ||
name: String, | ||
}) | ||
.listen(apiPort); | ||
|
||
// subscribe to the artists change events stream (SSE) | ||
var ess = require('agco-event-source-stream'); | ||
|
||
ess(apiHost + '/artists/changes/stream') | ||
.on('data', function(data) { | ||
console.log('recevied artist change event', data) | ||
}); | ||
let ess = require('agco-event-source-stream'); | ||
|
||
ess(apiHost + '/artists/changes/stream').on('data', function(data) { | ||
console.log('recevied artist change event', data); | ||
}); | ||
|
||
// add some data | ||
var $http = require('http-as-promised'); | ||
|
||
var sepultura = { | ||
artists: [{ | ||
name: "Sepultura" | ||
}] | ||
let $http = require('http-as-promised'); | ||
|
||
let sepultura = { | ||
artists: [ | ||
{ | ||
name: 'Sepultura', | ||
}, | ||
], | ||
}; | ||
|
||
// wait a bit for the event stream to open before posting the artist | ||
setTimeout(function() { | ||
$http.post(apiHost + '/artists', {json: sepultura}) | ||
.spread(function (response, body) { | ||
console.log(body); | ||
}) | ||
.catch(function (error) { | ||
console.error(error); | ||
}); | ||
$http | ||
.post(apiHost + '/artists', { json: sepultura }) | ||
.spread(function(response, body) { | ||
console.log(body); | ||
}) | ||
.catch(function(error) { | ||
console.error(error); | ||
}); | ||
}, 2000); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,8 @@ | |
}, | ||
"version": "1.0.0", | ||
"author": "", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"engines": { | ||
"node": ">=4.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.