Allow predictions to be saved
This commit is contained in:
20
src/routes/prediction.ts
Normal file
20
src/routes/prediction.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import express from 'express';
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
import db from '../db';
|
||||
import PredictionModel from '../models/prediction';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
|
||||
router.post('/prediction/new', (req, res, next) => {
|
||||
console.log("New Prediction");
|
||||
console.log(JSON.stringify(req.body));
|
||||
new PredictionModel(req.body).save((err, data) => {
|
||||
if(err) return next(err);
|
||||
db.log(req, 'predictions', {_id: data._id}, data.toObject());
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
Reference in New Issue
Block a user