You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
928 B
JavaScript
40 lines
928 B
JavaScript
const express = require('express')
|
|
const axios = require('axios')
|
|
const { v4 } = require('uuid')
|
|
|
|
const { push } = require('../uuids')
|
|
|
|
const router = express.Router()
|
|
|
|
router.post('/', async (req, res) => {
|
|
try {
|
|
const token = req.body.token;
|
|
const r = await axios.post('https://cms.aplesports.com/api/collections/get/nuke', {
|
|
filter: {
|
|
token,
|
|
},
|
|
}, {
|
|
headers: {
|
|
'Cockpit-Token': process.env.CMS_TOKEN,
|
|
},
|
|
})
|
|
if (r.data.entries.length === 1) {
|
|
const id = v4();
|
|
push(id)
|
|
res.json({
|
|
session: id,
|
|
})
|
|
} else {
|
|
res.status(403).json({
|
|
message: 'Forbidden',
|
|
})
|
|
}
|
|
} catch(e) {
|
|
res.status(403).json({
|
|
message: 'Forbidden',
|
|
})
|
|
}
|
|
})
|
|
|
|
module.exports = router
|