From 1045cddaebd0570748d40f45799945c45c9ccf3c Mon Sep 17 00:00:00 2001 From: catarak Date: Fri, 17 Jun 2016 16:40:13 -0400 Subject: [PATCH] figure out how redux-thunk works --- package.json | 3 ++- server/controllers/project.controller.js | 1 + server/models/project.js | 4 +++- shared/containers/IDEView/IDEView.jsx | 2 ++ shared/redux/actions/index.js | 13 ++++++++++--- shared/redux/reducers/files.js | 5 +++++ shared/redux/reducers/project.js | 1 + 7 files changed, 24 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0d1de282..474da065 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "react-router": "^2.4.1", "redux": "^3.5.2", "redux-form": "^5.2.5", - "redux-thunk": "^2.1.0" + "redux-thunk": "^2.1.0", + "shortid": "^2.2.6" } } diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index b93c2e95..9f9c6c01 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -8,6 +8,7 @@ export function createProject(req, res) { }, function(err, newProject) { if (err) { return res.json({success: false}) } return res.json({ + id: newProject._id, name: newProject.name, file: { name: newProject.file.name, diff --git a/server/models/project.js b/server/models/project.js index 046b4bae..44364251 100644 --- a/server/models/project.js +++ b/server/models/project.js @@ -1,5 +1,6 @@ import mongoose from 'mongoose'; const Schema = mongoose.Schema; +import shortid from 'shortid'; const fileSchema = new Schema({ name: {type: String, default: 'sketch.js'}, @@ -9,7 +10,8 @@ const fileSchema = new Schema({ const projectSchema = new Schema({ name: {type: String, default: "Hello p5.js, it's the server"}, user: {type: Schema.Types.ObjectId, ref: 'User'}, - file: {type: fileSchema} + file: {type: fileSchema}, + _id: {type: String, default: shortid.generate} }, {timestamps: true}); export default mongoose.model('Project', projectSchema); \ No newline at end of file diff --git a/shared/containers/IDEView/IDEView.jsx b/shared/containers/IDEView/IDEView.jsx index fc27642f..bd8b9f3e 100644 --- a/shared/containers/IDEView/IDEView.jsx +++ b/shared/containers/IDEView/IDEView.jsx @@ -13,6 +13,8 @@ class IDEView extends React.Component { return (