init from origin + update
This commit is contained in:
42
server/routers/publicium/index.js
Normal file
42
server/routers/publicium/index.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const { Router, json } = require('express')
|
||||
const cors = require('cors')
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.use(json())
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
router.use(cors())
|
||||
}
|
||||
|
||||
router.get('/games/trending', (req, res) => res.status(200).send(require('./mocks/games/trending.json')))
|
||||
|
||||
router.get('/users/top-load', (req, res) => res.status(200).send(require('./mocks/users/top-load.json')))
|
||||
|
||||
router.get('/maps/trending', (req, res) => res.status(200).send(require('./mocks/maps/trending.json')))
|
||||
|
||||
router.get('/search', (req, res) => res.status(200).send(require('./mocks/search.json')))
|
||||
|
||||
router.get('/games', (req, res) => res.status(200).send(require('./mocks/games.json')))
|
||||
router.get('/games/:id', (req, res) => {
|
||||
const games = require('./mocks/games.json')
|
||||
|
||||
const game = games.find((game) => game.id === Number.parseInt(req.params.id, 10))
|
||||
|
||||
if (!game) {
|
||||
return res.status(404).send({
|
||||
code: -3,
|
||||
message: 'Game not found',
|
||||
})
|
||||
}
|
||||
|
||||
res.status(200).send(game)
|
||||
})
|
||||
|
||||
router.get('/users/:id', (req, res) => res.status(200).send(require('./mocks/users/12.json')))
|
||||
|
||||
router.get('/users/:id/collection', (req, res) => res.status(200).send(require('./mocks/users/12/collection.json')))
|
||||
|
||||
router.get('/maps/by/:id', (req, res) => res.send(require('./mocks/maps/by/id.json')))
|
||||
|
||||
module.exports = router
|
||||
17
server/routers/publicium/mocks/games.json
Normal file
17
server/routers/publicium/mocks/games.json
Normal file
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Black Mesa",
|
||||
"logo": "bms"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Minecraft",
|
||||
"logo": "mc"
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"name": "CS: GO",
|
||||
"logo": "csgo"
|
||||
}
|
||||
]
|
||||
22
server/routers/publicium/mocks/games/trending.json
Normal file
22
server/routers/publicium/mocks/games/trending.json
Normal file
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Black Mesa",
|
||||
"logo": "bms"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Minecraft",
|
||||
"logo": "mc"
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"name": "CS: GO",
|
||||
"logo": "csgo"
|
||||
},
|
||||
{
|
||||
"id": 43,
|
||||
"name": "Left 4 Dead",
|
||||
"logo": "l4d"
|
||||
}
|
||||
]
|
||||
20
server/routers/publicium/mocks/maps/by/id.json
Normal file
20
server/routers/publicium/mocks/maps/by/id.json
Normal file
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"id": 302,
|
||||
"name": "Lambda Core 1",
|
||||
"logo": "lambda-1.png",
|
||||
"game": 1
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"name": "Xen Factory 2",
|
||||
"logo": "bms-xen2.png",
|
||||
"game": 1
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Office Complex 4",
|
||||
"logo": "bms-office4.png",
|
||||
"game": 1
|
||||
}
|
||||
]
|
||||
26
server/routers/publicium/mocks/maps/trending.json
Normal file
26
server/routers/publicium/mocks/maps/trending.json
Normal file
@@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"id": 302,
|
||||
"name": "Lambda Core 1",
|
||||
"logo": "lambda-1.png",
|
||||
"game": 1
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Inferno",
|
||||
"logo": "csgo-inferno.png",
|
||||
"game": 31
|
||||
},
|
||||
{
|
||||
"id": 43,
|
||||
"name": "Ice Spikes",
|
||||
"logo": "mc-icespk.png",
|
||||
"game": 12
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Dust 2",
|
||||
"logo": "csgo-dust2.png",
|
||||
"game": 31
|
||||
}
|
||||
]
|
||||
28
server/routers/publicium/mocks/search.json
Normal file
28
server/routers/publicium/mocks/search.json
Normal file
@@ -0,0 +1,28 @@
|
||||
[
|
||||
{
|
||||
"type": "game",
|
||||
"item": {
|
||||
"id": 1,
|
||||
"name": "Black Mesa",
|
||||
"logo": "bms-logo.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "map",
|
||||
"item": {
|
||||
"id": 302,
|
||||
"name": "Lambda Core 1",
|
||||
"logo": "lambda-1.png",
|
||||
"game": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "map",
|
||||
"item": {
|
||||
"id": 21,
|
||||
"name": "Xen Factory 2",
|
||||
"logo": "bms-xen2.png",
|
||||
"game": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
5
server/routers/publicium/mocks/users/12.json
Normal file
5
server/routers/publicium/mocks/users/12.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Gordon Freeman",
|
||||
"avatar": "user.png"
|
||||
}
|
||||
40
server/routers/publicium/mocks/users/12/collection.json
Normal file
40
server/routers/publicium/mocks/users/12/collection.json
Normal file
@@ -0,0 +1,40 @@
|
||||
[
|
||||
{
|
||||
"game": 1,
|
||||
"maps": [
|
||||
{
|
||||
"id": 302,
|
||||
"name": "Lambda Core 1",
|
||||
"logo": "lambda-1.png",
|
||||
"game": 1,
|
||||
"size": 12280
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"name": "Xen Factory 2",
|
||||
"logo": "bms-xen2.png",
|
||||
"game": 1,
|
||||
"size": 14760
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Office Complex 4",
|
||||
"logo": "bms-office4.png",
|
||||
"game": 1,
|
||||
"size": 9810
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"game": 12,
|
||||
"maps": [
|
||||
{
|
||||
"id": 43,
|
||||
"name": "Ice Spikes",
|
||||
"logo": "mc-icespk.png",
|
||||
"game": 12,
|
||||
"size": 43210
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
22
server/routers/publicium/mocks/users/top-load.json
Normal file
22
server/routers/publicium/mocks/users/top-load.json
Normal file
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Foo Bar",
|
||||
"avatar": "user.png"
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"name": "Holy Radar",
|
||||
"avatar": "user.png"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Gordon Freeman",
|
||||
"avatar": "user.png"
|
||||
},
|
||||
{
|
||||
"id": 43,
|
||||
"name": "Portator Defunctorum",
|
||||
"avatar": "user.png"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user