{"size": 716, "ext": "js", "max_stars_repo_path": "server/src/routes/races.js", "max_stars_repo_name": "janpro0706/LetsRun", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/src/routes/races.js", "max_issues_repo_name": "janpro0706/LetsRun", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/src/routes/races.js", "max_forks_repo_name": "janpro0706/LetsRun", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.4571428571, "max_line_length": 50, "alphanum_fraction": 0.5502793296}
/**
 * Created by janpr on 2016-11-20.
 */

import pollyfill from 'babel-polyfill';
import { Router } from 'express';
import { Race } from '../model';
import { Schema } from 'mongoose';

const router = Router();

router.post('/', (req, res) => {
    // token auth required

    // resolve userId
    // TEMP req with userId, instead of token
    let userId = Schema.ObjectId(req.body.userId);

    let race = new Race({
        userId: userId,
        isMulti: false,
        status: 0
    });

    race.save().then(data => {
        console.dir(data);
        res.status(200).send({
            code: 0,
            msg: 'race created',
            raceId: data._id
        });
    });
});

module.exports = router;