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

View file

@ -1,15 +1,15 @@
'use strict';
const config = require('config');
const knex = require('knex')({
client: 'mysql',
connection: config.mysql,
migrations: {
directory: __dirname + '/../setup/knex/migrations'
}
});
knex.migrate.latest();
module.exports = knex;
'use strict';
const config = require('config');
const knex = require('knex')({
client: 'mysql',
connection: config.mysql,
migrations: {
directory: __dirname + '/../setup/knex/migrations'
}
});
knex.migrate.latest();
module.exports = knex;

View file

@ -1,8 +1,5 @@
'use strict';
const config = require('config');
const knex = require('../knex');
module.exports.list = () => {
return knex('namespaces');
};
'use strict';
const knex = require('../knex');
module.exports.list = () => knex('namespaces');

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
};