From 1debf66cde02c86c277286331c837822fac24e3e Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 28 Nov 2020 01:43:14 +0300 Subject: feat: move logs to another service --- src/services/events/event.model.js | 2 +- src/services/events/log.model.js | 7 ------- src/services/events/log.schema.js | 7 ------- src/services/index.js | 2 ++ src/services/logs/log.model.js | 7 +++++++ src/services/logs/log.schema.js | 7 +++++++ src/services/logs/log.service.js | 9 +++++++++ 7 files changed, 26 insertions(+), 15 deletions(-) delete mode 100644 src/services/events/log.model.js delete mode 100644 src/services/events/log.schema.js create mode 100644 src/services/logs/log.model.js create mode 100644 src/services/logs/log.schema.js create mode 100644 src/services/logs/log.service.js diff --git a/src/services/events/event.model.js b/src/services/events/event.model.js index 56ba3c9..660cb1a 100644 --- a/src/services/events/event.model.js +++ b/src/services/events/event.model.js @@ -1,7 +1,7 @@ const cron = require('cron'); const { model } = require('mongoose'); const schema = require('./event.schema.js'); -const LogModel = require('./log.model.js'); +const LogModel = require('../logs/log.model.js'); const CronJob = cron.CronJob; diff --git a/src/services/events/log.model.js b/src/services/events/log.model.js deleted file mode 100644 index 64b7da6..0000000 --- a/src/services/events/log.model.js +++ /dev/null @@ -1,7 +0,0 @@ -const { model } = require('mongoose'); -const schema = require('./log.schema.js'); - -const Model = model('Log', schema); - - -module.exports = Model; diff --git a/src/services/events/log.schema.js b/src/services/events/log.schema.js deleted file mode 100644 index bb8d4a5..0000000 --- a/src/services/events/log.schema.js +++ /dev/null @@ -1,7 +0,0 @@ -const { Schema, Types } = require('mongoose'); - -module.exports = new Schema({ - eventId: Types.ObjectId, - message: String -}, { timestamps: true }); - diff --git a/src/services/index.js b/src/services/index.js index b8ef1db..e02a4b8 100644 --- a/src/services/index.js +++ b/src/services/index.js @@ -1,10 +1,12 @@ const Users = require('./users/user.service.js'); const Events = require('./events/event.service.js'); +const Logs = require('./logs/log.service.js'); const Auth = require('./auth/auth.service.js'); module.exports = app => { app.configure(Users); app.configure(Events); + app.configure(Logs); app.configure(Auth); app.get('/ping', (req, res) => res.send('pong')); diff --git a/src/services/logs/log.model.js b/src/services/logs/log.model.js new file mode 100644 index 0000000..64b7da6 --- /dev/null +++ b/src/services/logs/log.model.js @@ -0,0 +1,7 @@ +const { model } = require('mongoose'); +const schema = require('./log.schema.js'); + +const Model = model('Log', schema); + + +module.exports = Model; diff --git a/src/services/logs/log.schema.js b/src/services/logs/log.schema.js new file mode 100644 index 0000000..bb8d4a5 --- /dev/null +++ b/src/services/logs/log.schema.js @@ -0,0 +1,7 @@ +const { Schema, Types } = require('mongoose'); + +module.exports = new Schema({ + eventId: Types.ObjectId, + message: String +}, { timestamps: true }); + diff --git a/src/services/logs/log.service.js b/src/services/logs/log.service.js new file mode 100644 index 0000000..899ec86 --- /dev/null +++ b/src/services/logs/log.service.js @@ -0,0 +1,9 @@ +const service = require('feathers-mongoose'); +const Model = require('./log.model.js'); + +const LogService = service({ Model }); + +module.exports = app => { + app.use('/logs', LogService); +}; + -- cgit v1.2.3