Some bits for ReactJS-based client.

This commit is contained in:
Tomas Bures 2017-05-28 18:49:00 +02:00
parent 115d254baf
commit 4f52b571c9
27 changed files with 2326 additions and 202 deletions

24
lib/router-async.js Normal file
View file

@ -0,0 +1,24 @@
'use strict';
const express = require('express');
function safeHandler(handler) {
return function(req, res) {
handler(req, res).catch(error => res.status(500).send(error.message));
};
}
function create() {
const router = new express.Router();
router.getAsync = (path, asyncFn) => router.get(path, safeHandler(asyncFn));
router.postAsync = (path, asyncFn) => router.post(path, safeHandler(asyncFn));
return router;
}
module.exports = {
create
};