Haris Razis
4 years ago
15 changed files with 2127 additions and 9 deletions
@ -1,6 +1,22 @@ |
|||||
<component name="InspectionProjectProfileManager"> |
<component name="InspectionProjectProfileManager"> |
||||
<profile version="1.0"> |
<profile version="1.0"> |
||||
<option name="myName" value="Project Default" /> |
<option name="myName" value="Project Default" /> |
||||
|
<inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true"> |
||||
|
<option name="myValues"> |
||||
|
<value> |
||||
|
<list size="7"> |
||||
|
<item index="0" class="java.lang.String" itemvalue="nobr" /> |
||||
|
<item index="1" class="java.lang.String" itemvalue="noembed" /> |
||||
|
<item index="2" class="java.lang.String" itemvalue="comment" /> |
||||
|
<item index="3" class="java.lang.String" itemvalue="noscript" /> |
||||
|
<item index="4" class="java.lang.String" itemvalue="embed" /> |
||||
|
<item index="5" class="java.lang.String" itemvalue="script" /> |
||||
|
<item index="6" class="java.lang.String" itemvalue="shapedividertop" /> |
||||
|
</list> |
||||
|
</value> |
||||
|
</option> |
||||
|
<option name="myCustomValuesEnabled" value="true" /> |
||||
|
</inspection_tool> |
||||
<inspection_tool class="JSUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> |
<inspection_tool class="JSUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> |
||||
<inspection_tool class="JSValidateTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> |
<inspection_tool class="JSValidateTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> |
||||
</profile> |
</profile> |
||||
|
@ -1,11 +1,11 @@ |
|||||
FROM node:latest |
FROM node:latest |
||||
|
|
||||
WORKDIR /usr/src/app |
WORKDIR /usr/src/app/client |
||||
|
|
||||
COPY package*.json ./ |
COPY package*.json ./ |
||||
|
|
||||
RUN npm install |
RUN npm install |
||||
COPY . . |
|
||||
|
|
||||
EXPOSE 6000 |
EXPOSE 6000 |
||||
CMD [ "npm", "start" ] |
|
||||
|
CMD [ "npm", "run", "dev" ] |
@ -1,4 +1,3 @@ |
|||||
require('./services/socket') |
require('./services/socket') |
||||
|
|
||||
|
console.log('Client running...') |
||||
console.log('hello world') |
|
File diff suppressed because it is too large
@ -0,0 +1,19 @@ |
|||||
|
const mongoose = require('mongoose'); |
||||
|
const faker = require('faker') |
||||
|
const Athlete = mongoose.model('Athlete'); |
||||
|
|
||||
|
saveAthlete = async (mac, socketID) => { |
||||
|
const newAthlete = new Athlete({ |
||||
|
id: mac, |
||||
|
socketID: socketID, |
||||
|
name: faker.name.findName() |
||||
|
}) |
||||
|
|
||||
|
try { |
||||
|
await newAthlete.save(); |
||||
|
} catch (err) { |
||||
|
console.log(err); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = {saveAthlete} |
@ -0,0 +1,11 @@ |
|||||
|
const mongoose = require('mongoose'); |
||||
|
const {Schema} = mongoose; |
||||
|
|
||||
|
const AthleteSchema = new Schema({ |
||||
|
id: String, |
||||
|
socketID: String, |
||||
|
name: String, |
||||
|
_trainer: {type: Schema.Types.ObjectId, ref: 'User'} |
||||
|
}); |
||||
|
|
||||
|
mongoose.model('Athlete', AthleteSchema); |
@ -0,0 +1,41 @@ |
|||||
|
const express = require('express') |
||||
|
const router = express.Router(); |
||||
|
const mongoose = require('mongoose'); |
||||
|
const {requireAuth} = require('../middlewares/middleware'); |
||||
|
|
||||
|
const Athlete = mongoose.model('Athlete'); |
||||
|
|
||||
|
router.get('/api/athletes', async (req, res) => { |
||||
|
const athletes = await Athlete.find(); |
||||
|
res.send(athletes); |
||||
|
}); |
||||
|
|
||||
|
//add a new athlete
|
||||
|
router.get('/api/athletes/new', requireAuth, (req, res) => { |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
//add a new athlete
|
||||
|
router.post('/api/athletes', requireAuth, (req, res) => { |
||||
|
}); |
||||
|
|
||||
|
router.get('/api/athletes/:id', requireAuth, async (req, res) => { |
||||
|
const athlete = await Athlete.findById(req.params.id); |
||||
|
res.send(athlete) |
||||
|
}); |
||||
|
|
||||
|
router.get('/api/athletes/:id/edit', requireAuth, async (req, res) => { |
||||
|
const athlete = await Athlete.findById(req.params.id) |
||||
|
res.send(athlete) |
||||
|
}); |
||||
|
|
||||
|
router.put('/api/athletes/:id', requireAuth, async (req, res) => { |
||||
|
const {id, user} = req.params |
||||
|
await Athlete.findByIdAndUpdate(id, user) |
||||
|
}); |
||||
|
|
||||
|
router.delete('/api/athlete/:id', requireAuth, async (req, res) => { |
||||
|
await Athlete.findByIdAndDelete(req.params.id) |
||||
|
}); |
||||
|
|
||||
|
module.exports = router; |
Loading…
Reference in new issue