Last active
March 19, 2017 12:02
-
-
Save hakant/85fbfa3f3d77f82c2b17457a96356d09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/', catchAsyncErrors(async function (req, res, next) { | |
var request = new GetIdeasRequest(); | |
request.user = req.user; | |
var response = await application.ExecuteAsync<GetIdeasRequest, GetIdeasResponse>(request); | |
res.json(response.ideas); | |
})); | |
router.post("/add", catchAsyncErrors(async function (req, res, next) { | |
var request = new InsertIdeaRequest(); | |
request.user = req.user; | |
request.idea = <IIdea>req.body; | |
await application.ExecuteAsync<InsertIdeaRequest, InsertIdeaResponse>(request); | |
res.sendStatus(200); | |
})); | |
router.post("/edit-title", catchAsyncErrors(async function (req, res, next) { | |
var request = new EditIdeaRequest(); | |
request.user = req.user; | |
request.idea = <IIdea>req.body; | |
request.mode = EditMode.Title; | |
await application.ExecuteAsync<EditIdeaRequest, EditIdeaResponse>(request); | |
res.sendStatus(200); | |
})); | |
router.post("/edit-overview", catchAsyncErrors(async function (req, res, next) { | |
var request = new EditIdeaRequest(); | |
request.user = req.user; | |
request.idea = <IIdea>req.body; | |
request.mode = EditMode.Overview; | |
await application.ExecuteAsync<EditIdeaRequest, EditIdeaResponse>(request); | |
res.sendStatus(200); | |
})); | |
router.post("/edit-description", catchAsyncErrors(async function (req, res, next) { | |
var request = new EditIdeaRequest(); | |
request.user = req.user; | |
request.idea = <IIdea>req.body; | |
request.mode = EditMode.Description; | |
await application.ExecuteAsync<EditIdeaRequest, EditIdeaResponse>(request); | |
res.sendStatus(200); | |
})); | |
router.post("/like", catchAsyncErrors(async function (req, res, next) { | |
var request = new ToggleIdeaLikeRequest(); | |
request.user = req.user; | |
request.ideaId = req.body.ideaId | |
await application.ExecuteAsync<ToggleIdeaLikeRequest, ToggleIdeaLikeResponse>(request); | |
res.sendStatus(200); | |
})); | |
router.post("/join", catchAsyncErrors(async function (req, res, next) { | |
var request = new JoinIdeaRequest(); | |
request.user = req.user; | |
request.ideaId = req.body.ideaId | |
await application.ExecuteAsync<JoinIdeaRequest, JoinIdeaResponse>(request); | |
res.sendStatus(200); | |
})); | |
router.post("/unjoin", catchAsyncErrors(async function (req, res, next) { | |
var request = new LeaveIdeaRequest(); | |
request.user = req.user; | |
request.ideaId = req.body.ideaId | |
await application.ExecuteAsync<LeaveIdeaRequest, LeaveIdeaResponse>(request); | |
res.sendStatus(200); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment