Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 8795c73

Browse files
committed
feature/system-notifcations - added system-notification service
1 parent adfbc7e commit 8795c73

File tree

5 files changed

+124
-1
lines changed

5 files changed

+124
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"dev:debug": "npm run clear && concurrently '$npm_package_config_mongoDev' 'wait-on tcp:27017 && NODE_ENV=development nodemon --inspect server/'",
4242
"dev": "npm run clear && concurrently '$npm_package_config_mongoDev' 'wait-on tcp:27017 && NODE_ENV=development DEBUG=feathers nodemon server/'",
4343
"dev:noseed": "concurrently 'mongod --dbpath data' 'wait-on tcp:27017 && NODE_ENV=development DEBUG=feathers nodemon server/'",
44-
"dev:win": "npm run clear && concurrently \"mongod --dbpath data\" \"wait-on tcp:27017&&SET NODE_ENV=development&&SET DEBUG=feathers&& nodemon --inspect server/\"",
44+
"dev:win": "npm run clear && concurrently \"mongod --dbpath /data/db\" \"wait-on tcp:27017&&cross-env NODE_ENV=development&&cross-env DEBUG=feathers&& nodemon --inspect server/\"",
4545
"mocha": "npm run clear && $npm_package_config_concurrently '$npm_package_config_mongoDev &>/dev/null' 'wait-on tcp:27017 && NODE_ENV=test $npm_package_config_mocha'",
4646
"coverage": "npm run clear && $npm_package_config_concurrently '$npm_package_config_mongoDev &>/dev/null' 'wait-on tcp:27017 && NODE_ENV=test istanbul cover $npm_package_config_mochaCoverage'"
4747
},
@@ -105,6 +105,7 @@
105105
"devDependencies": {
106106
"babel-eslint": "~8.2.1",
107107
"concurrently": "~3.5.1",
108+
"cross-env": "^5.1.4",
108109
"eslint": "~4.16.0",
109110
"istanbul": "1.1.0-alpha.1",
110111
"mocha": "~5.0.4",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// system-notifications-model.js - A mongoose model
2+
//
3+
// See http://mongoosejs.com/docs/models.html
4+
// for more of what you can do here.
5+
module.exports = function (app) {
6+
const mongooseClient = app.get('mongooseClient');
7+
const systemNotifications = new mongooseClient.Schema({
8+
type: { type: String, default: 'info' },
9+
title: { type: String },
10+
content: { type: String },
11+
slot: { type: String },
12+
showOnce: { type: Boolean, default: true },
13+
requireConfirmation: { type: Boolean, default: false },
14+
createdAt: { type: Date, default: Date.now },
15+
updatedAt: { type: Date, default: Date.now },
16+
wasSeeded: { type: Boolean }
17+
});
18+
19+
return mongooseClient.model('systemNotifications', systemNotifications);
20+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint no-console: 1 */
2+
console.warn('You are using the default filter for the system-notifications service. For more information about event filters see https://docs.feathersjs.com/api/events.html#event-filtering'); // eslint-disable-line no-console
3+
4+
module.exports = function (data, connection, hook) { // eslint-disable-line no-unused-vars
5+
return data;
6+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const { unless, isProvider } = require('feathers-hooks-common');
2+
const { isVerified } = require('feathers-authentication-management').hooks;
3+
const { authenticate } = require('feathers-authentication').hooks;
4+
const isModerator = require('../../hooks/is-moderator-boolean');
5+
6+
module.exports = {
7+
before: {
8+
all: [],
9+
find: [
10+
unless(isModerator())
11+
],
12+
get: [
13+
unless(isModerator())
14+
],
15+
create: [
16+
authenticate('jwt'),
17+
// Allow seeder to seed contributions
18+
unless(isProvider('server'),
19+
isVerified()
20+
),
21+
],
22+
update: [
23+
authenticate('jwt'),
24+
unless(isProvider('server'),
25+
isVerified()
26+
),
27+
unless(isModerator())
28+
],
29+
patch: [
30+
authenticate('jwt'),
31+
unless(isProvider('server'),
32+
isVerified()
33+
),
34+
unless(isModerator())
35+
],
36+
remove: [
37+
authenticate('jwt'),
38+
isVerified(),
39+
unless(isModerator())
40+
]
41+
},
42+
43+
after: {
44+
all: [
45+
],
46+
find: [
47+
],
48+
get: [
49+
],
50+
create: [
51+
],
52+
update: [
53+
],
54+
patch: [],
55+
remove: []
56+
},
57+
58+
error: {
59+
all: [],
60+
find: [],
61+
get: [],
62+
create: [],
63+
update: [],
64+
patch: [],
65+
remove: []
66+
}
67+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Initializes the `system-notifications` service on path `/system-notifications`
2+
const createService = require('feathers-mongoose');
3+
const createModel = require('../../models/system-notifications.model');
4+
const hooks = require('./system-notifications.hooks');
5+
const filters = require('./system-notifications.filters');
6+
7+
module.exports = function () {
8+
const app = this;
9+
const Model = createModel(app);
10+
const paginate = app.get('paginate');
11+
12+
const options = {
13+
name: 'system-notifications',
14+
Model,
15+
paginate
16+
};
17+
18+
// Initialize our service with any options it requires
19+
app.use('/system-notifications', createService(options));
20+
21+
// Get our initialized service so that we can register hooks and filters
22+
const service = app.service('system-notifications');
23+
24+
service.hooks(hooks);
25+
26+
if (service.filter) {
27+
service.filter(filters);
28+
}
29+
};

0 commit comments

Comments
 (0)