diff options
author | eug-vs <eug-vs@keemail.me> | 2020-11-14 14:56:12 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-11-14 14:56:12 +0300 |
commit | fd3efcdec584d550f70fb473386e01086e8238e0 (patch) | |
tree | d5019e835f70fd70fe6825704e8aa7c010ed8ce3 /services | |
parent | 87306ea2e4ffad7b8c588da0423ecf199575ac9c (diff) | |
download | bsu-fantom-fd3efcdec584d550f70fb473386e01086e8238e0.tar.gz |
feat: add Users and Events services
Diffstat (limited to 'services')
-rw-r--r-- | services/events/event.model.js | 6 | ||||
-rw-r--r-- | services/events/event.schema.js | 16 | ||||
-rw-r--r-- | services/events/event.service.js | 7 | ||||
-rw-r--r-- | services/index.js | 10 | ||||
-rw-r--r-- | services/users/user.model.js | 6 | ||||
-rw-r--r-- | services/users/user.schema.js | 14 | ||||
-rw-r--r-- | services/users/user.service.js | 7 |
7 files changed, 66 insertions, 0 deletions
diff --git a/services/events/event.model.js b/services/events/event.model.js new file mode 100644 index 0000000..7bac9d5 --- /dev/null +++ b/services/events/event.model.js @@ -0,0 +1,6 @@ +const { model } = require('mongoose'); +const eventSchema = require('./event.schema.js'); + +module.exports = model('Event', eventSchema); + + diff --git a/services/events/event.schema.js b/services/events/event.schema.js new file mode 100644 index 0000000..555153b --- /dev/null +++ b/services/events/event.schema.js @@ -0,0 +1,16 @@ +const { Schema, Types } = require('mongoose'); + +module.exports = new Schema({ + startDate: { + type: Date, + required: true + }, + endDate: { + type: Date, + required: true + }, + attendanceId: Number, + conferenceId: Number, + participantIds: [Types.ObjectId] +}, { timestamps: true }); + diff --git a/services/events/event.service.js b/services/events/event.service.js new file mode 100644 index 0000000..e9e7e50 --- /dev/null +++ b/services/events/event.service.js @@ -0,0 +1,7 @@ +const service = require('feathers-mongoose'); +const Model = require('./event.model.js'); + +const EventService = service({ Model }) + +module.exports = app => app.use('/events', EventService); + diff --git a/services/index.js b/services/index.js new file mode 100644 index 0000000..f2d65d0 --- /dev/null +++ b/services/index.js @@ -0,0 +1,10 @@ +const Users = require('./users/user.service.js'); +const Events = require('./events/event.service.js'); + +module.exports = app => { + app.configure(Users); + app.configure(Events); + + app.get('/ping', (req, res) => res.send('pong')); +}; + diff --git a/services/users/user.model.js b/services/users/user.model.js new file mode 100644 index 0000000..74a83ae --- /dev/null +++ b/services/users/user.model.js @@ -0,0 +1,6 @@ +const { model } = require('mongoose'); +const userSchema = require('./user.schema.js'); + +module.exports = model('User', userSchema); + + diff --git a/services/users/user.schema.js b/services/users/user.schema.js new file mode 100644 index 0000000..f2c98ef --- /dev/null +++ b/services/users/user.schema.js @@ -0,0 +1,14 @@ +const { Schema } = require('mongoose'); + +module.exports = new Schema({ + username: { + type: String, + unique: true, + required: true + }, + password: { + type: String, + required: true + } +}, { timestamps: true }); + diff --git a/services/users/user.service.js b/services/users/user.service.js new file mode 100644 index 0000000..67f2ae6 --- /dev/null +++ b/services/users/user.service.js @@ -0,0 +1,7 @@ +const service = require('feathers-mongoose'); +const Model = require('./user.model.js'); + +const UserService = service({ Model }) + +module.exports = app => app.use('/users', UserService); + |