Some bits for ReactJS-based client.
This commit is contained in:
parent
115d254baf
commit
4f52b571c9
27 changed files with 2326 additions and 202 deletions
30
lib/knex.js
30
lib/knex.js
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
24
lib/router-async.js
Normal 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
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue