1
0
Fork 0
mirror of https://github.com/voltbonn/diversity.volt.link.git synced 2024-05-13 08:21:30 +00:00

dumbly add answer to mongodb

This commit is contained in:
thomasrosen 2022-11-23 15:52:36 +01:00
parent 5332151b55
commit bb3a4fb6ee

View file

@ -1,6 +1,6 @@
require('dotenv').config()
// const getMongoDbContext = require('./getMongoDbContext.js')
const getMongoDbContext = require('./getMongoDbContext.js')
// const isDevEnvironment = process.env.environment === 'dev' || false
const path = require('path')
@ -287,10 +287,26 @@ app.get('/api/teams.json', function (req, res, next) {
}
})
app.post('/api/submit_data', function (req, res, next) {
const body = JSON.parse(req.body) || null
console.log(body)
res.sendStatus(200)
app.post('/api/save_answer', async function (req, res, next) {
const body = req.body
const answerDoc = {
questionKey: body.questionKey || null,
answerKey: body.answerKey || null,
metadata: {
timestamp: new Date(),
team_id: body.metadata.team_id || null,
team_name: body.metadata.team_name || null,
tact: body.metadata.tact || null,
relationToVolt: body.metadata.relationToVolt || null,
}
}
const mongodb = await getMongoDbContext()
const result = await mongodb.collections.answers.insertOne(answerDoc)
res.send(result)
// res.sendStatus(200)
res.end()
})