diff --git a/server/connections/mongo_conn.js b/server/connections/mongo_conn.js index 1a4fb98..9fe765f 100644 --- a/server/connections/mongo_conn.js +++ b/server/connections/mongo_conn.js @@ -3,6 +3,7 @@ const chalk = require('chalk') const {mongo_uri} = require('../config/keys'); require('../models/User'); +require('../models/Athlete'); mongoose.Promise = global.Promise; mongoose.connect(mongo_uri, { diff --git a/server/index.js b/server/index.js index 10ee245..5db37cb 100644 --- a/server/index.js +++ b/server/index.js @@ -6,11 +6,12 @@ const cors = require('cors') const history = require('connect-history-api-fallback'); const rateLimit = require('express-rate-limit'); -require('./services/socket')(server); require('./connections/mongo_conn'); +require('./services/socket')(server); const dataRoute = require('./routes/data') const authRoute = require('./routes/auth') +const athletesRoute = require('./routes/athletes') const passport = require('./services/passport'); const {session_secret} = require('./config/keys'); @@ -43,6 +44,7 @@ app.use(passport.session(undefined)); app.use(dataRoute) app.use(authRoute) +app.use(athletesRoute) app.use(history({ verbose: true diff --git a/server/models/Athlete.js b/server/models/Athlete.js new file mode 100644 index 0000000..7aa1df9 --- /dev/null +++ b/server/models/Athlete.js @@ -0,0 +1,10 @@ +const mongoose = require('mongoose'); +const {Schema} = mongoose; + +const AthleteSchema = new Schema({ + id: String, + name: String, + _trainer: {type: Schema.Types.ObjectId, ref: 'User'} +}); + +mongoose.model('Athlete', AthleteSchema); diff --git a/server/models/User.js b/server/models/User.js index 83ed3d2..c2bef3b 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -3,7 +3,7 @@ const {Schema} = mongoose; const userSchema = new Schema({ username: String, - password: String + password: String, }); mongoose.model('User', userSchema); \ No newline at end of file