Skip to content

Commit 2575343

Browse files
committed
first commit
0 parents  commit 2575343

File tree

12,360 files changed

+1366130
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

12,360 files changed

+1366130
-0
lines changed

.babelrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react"
5+
],
6+
"plugins": [
7+
"react-hot-loader/babel"
8+
]
9+
}

.~lock.carnet_de_bord.odt#

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
,simplonco,adamska-ps,09.08.2017 14:53,file:///home/simplonco/.config/libreoffice/4;

api/models/game.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import mongoose from 'mongoose';
2+
const Schema = mongoose.Schema;
3+
4+
const gameSchema = new Schema(
5+
{
6+
name: String,
7+
year: Number,
8+
description: String,
9+
picture: String,
10+
postdate: { type: Date, default: Date.now }
11+
}
12+
);
13+
14+
export default mongoose.model('Game', gameSchema);

api/routes/game.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Game from "../models/game";
2+
3+
const getGames = (req, res) => {
4+
Game.find(null, null, { sort: { postDate : 1 } }, (err, games) => {
5+
if (err) {
6+
res.send(err);
7+
}
8+
res.json(games);
9+
});
10+
}
11+
12+
const getGame = (req, res) => {
13+
const { id } = req.params;
14+
Game.findById(id, (err, game) => {
15+
if (err) {
16+
res.send(err);
17+
}
18+
res.json(game);
19+
});
20+
}
21+
22+
const postGame = (req, res) => {
23+
let game = Object.assign(new Game(), req.body);
24+
game.save(err => {
25+
if (err) {
26+
res.send(err);
27+
}
28+
res.json({ message: 'game created' });
29+
});
30+
}
31+
32+
const deleteGame = (req, res) => {
33+
Game.remove(
34+
{_id: req.params.id},
35+
err => {
36+
if (err) {
37+
res.send(err)
38+
}
39+
res.json({ message: 'game deleted' });
40+
}
41+
);
42+
}
43+
44+
export { getGames, getGame, postGame, deleteGame };
80.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)