p5.js-web-editor/server/controllers/project.controller.js

22 lines
462 B
JavaScript
Raw Normal View History

2016-06-17 18:11:52 +00:00
import Project from '../models/project'
export function createProject(req, res) {
if (req.user) {
Project.create({
user: req.user._id,
file: {}
}, function(err, newProject) {
if (err) { return res.json({success: false}) }
return res.json({
2016-06-17 20:40:13 +00:00
id: newProject._id,
2016-06-17 18:11:52 +00:00
name: newProject.name,
file: {
name: newProject.file.name,
content: newProject.file.content
}
});
});
} else {
res.json({success: false});
}
}