'use strict'; // 新增数据源 function addDataSource(opts) { return async function (ctx, next) { const models = ctx.fs.dc.models; try { let rslt = ctx.request.body; await models.DataSource.create(Object.assign({}, rslt)) ctx.status = 204; ctx.body = { message: '新建数据源成功' } } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: '新建数据源失败' } } } } module.exports = { addDataSource, }