mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-18 11:32:25 -05:00
c4652d82e2
* Updates spade.js vendor file, adds a sublime-project for developers to use * Moves server logic away from handlers * Moves session update logic to middleware, sets up server schema to autorender IDs as ObjectIDs * Modernizes the supermodel loading scheme and switches from constructor to initalize
22 lines
674 B
CoffeeScript
22 lines
674 B
CoffeeScript
errors = require '../commons/errors'
|
|
wrap = require 'co-express'
|
|
database = require '../commons/database'
|
|
|
|
mongoose = require 'mongoose'
|
|
CodeLog = require '../models/CodeLog'
|
|
LevelSession = require '../models/LevelSession'
|
|
|
|
module.exports =
|
|
post: wrap (req, res) ->
|
|
codeLog = database.initDoc(req, CodeLog)
|
|
database.assignBody(req, codeLog)
|
|
database.validateDoc(codeLog)
|
|
codeLog = yield codeLog.save()
|
|
|
|
# Update the level session with sessionID to include the new codelog.
|
|
yield LevelSession.update(
|
|
{_id: mongoose.Types.ObjectId(req.body.sessionID)},
|
|
{$push:{codeLogs: codeLog._id}}
|
|
)
|
|
|
|
res.status(201).send(codeLog.toObject())
|