diff options
Diffstat (limited to 'src/services/posts')
-rw-r--r-- | src/services/posts/posts.hooks.js | 33 | ||||
-rw-r--r-- | src/services/posts/posts.service.js | 22 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/services/posts/posts.hooks.js b/src/services/posts/posts.hooks.js new file mode 100644 index 0000000..39ac996 --- /dev/null +++ b/src/services/posts/posts.hooks.js @@ -0,0 +1,33 @@ +const {authenticate} = require('@feathersjs/authentication').hooks; + +module.exports = { + before: { + all: [authenticate('jwt')], + find: [], + get: [], + create: [], + update: [], + patch: [], + remove: [] + }, + + after: { + all: [], + find: [], + get: [], + create: [], + update: [], + patch: [], + remove: [] + }, + + error: { + all: [], + find: [], + get: [], + create: [], + update: [], + patch: [], + remove: [] + } +}; diff --git a/src/services/posts/posts.service.js b/src/services/posts/posts.service.js new file mode 100644 index 0000000..cacde6e --- /dev/null +++ b/src/services/posts/posts.service.js @@ -0,0 +1,22 @@ +// Initializes the `posts` service on path `/posts` +const createService = require('feathers-sequelize'); +const createModel = require('../../models/posts.model'); +const hooks = require('./posts.hooks'); + +module.exports = function (app) { + const Model = createModel(app); + const paginate = app.get('paginate'); + + const options = { + Model, + paginate + }; + + // Initialize our service with any options it requires + app.use('/posts', createService(options)); + + // Get our initialized service so that we can register hooks + const service = app.service('posts'); + + service.hooks(hooks); +}; |