Skip to content

Commit 0997d40

Browse files
Merge pull request Human-Connection#57 in HC/hc-api-feathers from feature/NEXT-274 to develop
* commit '456c06f9fae5a757edd4844a31c346e5077abae7': NEXT-274 - rename APP_SECRET to API_SECRET NEXT-274 - try to fix build NEXT-274 - try to fix travis build NEXT-274 - fixed tests NEXT-274 - added status service with maintenance flag and apiSecret
2 parents 7bb72aa + 456c06f commit 0997d40

File tree

19 files changed

+220
-23
lines changed

19 files changed

+220
-23
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ install:
99
# - yarn
1010
script:
1111
- cp ./config/local.example.json ./config/local.json
12-
- NODE_ENV=development npm test
12+
- npm run clear && NODE_ENV=test mocha test/ --recursive --timeout 10000 --exit
1313
- rm ./config/local.json
1414
services:
1515
- docker
16+
- mongodb
1617
before_install:
1718
- docker build -t humanconnection/api-feathers:alpha .
1819
after_success:
1920
- if [ "$TRAVIS_BRANCH" == "master" ]; then
2021
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
2122
docker push humanconnection/api-feathers:alpha;
2223
fi
23-
# - yarn run coverage
24+
# - yarn run coverage

config/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"url": "",
1414
"key": ""
1515
},
16+
"apiSecret": "TE9TqAk2xK[9EFJL",
1617
"sentry": {
1718
"dns": "SENTRY_DNS",
1819
"options": {

config/production.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"url": "THUMBOR_URL",
1919
"key": "THUMBOR_KEY"
2020
},
21+
"apiSecret": "API_SECRET",
2122
"authentication": {
2223
"secret": "AUTH_SECRET",
2324
"jwt": {

config/test.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"port": 3031,
3+
"baseURL": "http://localhost:3031",
4+
"seeder": {
5+
"runOnInit": false,
6+
"dropDatabase": false
7+
},
8+
"mongodb": "mongodb://localhost:27017/hc_api_test"
9+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"dev-win": "npm run clear && concurrently \"mongod --dbpath data\" \"wait-on tcp:27017&&SET NODE_ENV=development&& nodemon --inspect server/\"",
4343
"dev-noseed": "concurrently 'mongod --dbpath data' 'wait-on tcp:27017 && NODE_ENV=development nodemon --inspect server/'",
4444
"dev-win-noseed": "concurrently \"mongod --dbpath data\" \"wait-on tcp:27017 && nodemon --inspect server/\"",
45-
"mocha": "mocha test/ --recursive"
45+
"mocha": "npm run clear && concurrently --success first --kill-others 'mongod --dbpath data &>/dev/null' 'wait-on tcp:27017 && NODE_ENV=test mocha test/ --recursive --timeout 10000 --exit'"
4646
},
4747
"dependencies": {
4848
"body-parser": "~1.18.2",

server/models/status.model.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// status-model.js - A mongoose model
2+
//
3+
// See http://mongoosejs.com/docs/models.html
4+
// for more of what you can do here.
5+
6+
module.exports = function (app) {
7+
const mongooseClient = app.get('mongooseClient');
8+
const status = new mongooseClient.Schema({
9+
maintenance: { type: Boolean, default: false },
10+
updatedAt: { type: Date, default: Date.now }
11+
});
12+
13+
return mongooseClient.model('status', status);
14+
};

server/seeder/development/users-candos.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const seedHelpers = require('../../helper/seed-helpers');
22

33
module.exports = (seederstore) => {
44
let filter = ({type}) => type === 'cando';
5+
56
return {
67
services: [{
78
count: 80,

server/seeder/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ const _ = require('lodash');
1919
let configs = [...baseConfigs, ...developmentConfigs];
2020

2121
// seed service and add results to the seeder store
22-
const seedAndAssign = async (config, seeder) => {
22+
const seedAndAssign = async (config, seeder, app) => {
2323
const key = config.path;
24-
const res = await seeder.seed(config);
25-
if (_.isEmpty(seederstore[key])) {
26-
seederstore[key] = {};
24+
try {
25+
const res = await seeder.seed(config);
26+
if (_.isEmpty(seederstore[key])) {
27+
seederstore[key] = {};
28+
}
29+
_.merge(seederstore[key], _.mapKeys(res, '_id'));
30+
} catch (err) {
31+
app.error(err);
2732
}
28-
_.merge(seederstore[key], _.mapKeys(res, '_id'));
2933
};
3034

3135
module.exports = function (app = null, store = null) {
@@ -53,7 +57,7 @@ module.exports = function (app = null, store = null) {
5357
app.error('config was empty!');
5458
}
5559
await asyncForEach(config.services, async (service) => {
56-
await seedAndAssign(service, seeder);
60+
await seedAndAssign(service, seeder, app);
5761
});
5862
});
5963
app.info('>>>>>> SEEDING COMPLETED <<<<<<');
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/* eslint no-console: 1 */
2-
console.warn('You are using the default filter for the admin service. For more information about event filters see https://docs.feathersjs.com/api/events.html#event-filtering'); // eslint-disable-line no-console
3-
42
module.exports = function (data, connection, hook) { // eslint-disable-line no-unused-vars
5-
return data;
3+
return false;
64
};
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/* eslint no-console: 1 */
2-
console.warn('You are using the default filter for the badges service. For more information about event filters see https://docs.feathersjs.com/api/events.html#event-filtering'); // eslint-disable-line no-console
3-
42
module.exports = function (data, connection, hook) { // eslint-disable-line no-unused-vars
5-
return data;
3+
return false;
64
};

0 commit comments

Comments
 (0)