Skip to content

Commit

Permalink
added campaigns service
Browse files Browse the repository at this point in the history
  • Loading branch information
ojones committed Aug 6, 2017
1 parent 439a51c commit ff33d94
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/models/campaigns.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const NeDB = require('nedb');
const path = require('path');

module.exports = function (app) {
const dbPath = app.get('nedb');
const Model = new NeDB({
filename: path.join(dbPath, 'campaigns.db'),
autoload: true
});

return Model;
};
6 changes: 6 additions & 0 deletions src/services/campaigns/campaigns.filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint no-console: 1 */
console.warn('You are using the default filter for the campaigns service. For more information about event filters see https://docs.feathersjs.com/api/events.html#event-filtering'); // eslint-disable-line no-console

module.exports = function (data, connection, hook) { // eslint-disable-line no-unused-vars
return data;
};
33 changes: 33 additions & 0 deletions src/services/campaigns/campaigns.hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@


module.exports = {
before: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},

after: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},

error: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
};
29 changes: 29 additions & 0 deletions src/services/campaigns/campaigns.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Initializes the `campaigns` service on path `/campaigns`
const createService = require('feathers-nedb');
const createModel = require('../../models/campaigns.model');
const hooks = require('./campaigns.hooks');
const filters = require('./campaigns.filters');

module.exports = function () {
const app = this;
const Model = createModel(app);
const paginate = app.get('paginate');

const options = {
name: 'campaigns',
Model,
paginate
};

// Initialize our service with any options it requires
app.use('/campaigns', createService(options));

// Get our initialized service so that we can register hooks and filters
const service = app.service('campaigns');

service.hooks(hooks);

if (service.filter) {
service.filter(filters);
}
};
2 changes: 2 additions & 0 deletions src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const milestones = require('./milestones/milestones.service.js');
const givers = require('./givers/givers.service.js');
const reviewerRequests = require('./reviewer-requests/reviewer-requests.service.js');
const completionRequests = require('./completion-requests/completion-requests.service.js');
const campaigns = require('./campaigns/campaigns.service.js');
module.exports = function () {
const app = this; // eslint-disable-line no-unused-vars
app.configure(skunkworks);
Expand All @@ -14,4 +15,5 @@ module.exports = function () {
app.configure(givers);
app.configure(reviewerRequests);
app.configure(completionRequests);
app.configure(campaigns);
};
10 changes: 10 additions & 0 deletions test/services/campaigns.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const assert = require('assert');
const app = require('../../src/app');

describe('\'campaigns\' service', () => {
it('registered the service', () => {
const service = app.service('campaigns');

assert.ok(service, 'Registered the service');
});
});

0 comments on commit ff33d94

Please sign in to comment.