|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
import Noco from '../../Noco'; |
|
|
|
|
|
|
|
|
|
|
|
import { Request, Router } from 'express'; |
|
|
|
import { Request, Router } from 'express'; |
|
|
|
import { TestResetService } from '../../services/test/TestResetService'; |
|
|
|
import { TestResetService } from '../../services/test/TestResetService'; |
|
|
|
|
|
|
|
|
|
|
@ -11,7 +13,24 @@ export async function reset(req: Request<any, any>, res) { |
|
|
|
res.json(await service.process()); |
|
|
|
res.json(await service.process()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export async function sqliteExec(req: Request<any, any>, res) { |
|
|
|
|
|
|
|
const metaKnex = Noco.ncMeta.knex; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const result = await metaKnex.raw(req.body.sql); |
|
|
|
|
|
|
|
res.json({ |
|
|
|
|
|
|
|
body: result, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error('sqliteExec', e); |
|
|
|
|
|
|
|
res.status(500).json({ |
|
|
|
|
|
|
|
error: e, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const router = Router({ mergeParams: true }); |
|
|
|
const router = Router({ mergeParams: true }); |
|
|
|
|
|
|
|
|
|
|
|
router.post('/api/v1/meta/test/reset', reset); |
|
|
|
router.post('/api/v1/meta/test/reset', reset); |
|
|
|
|
|
|
|
router.post('/api/v1/meta/test/sqlite_exec', sqliteExec); |
|
|
|
|
|
|
|
|
|
|
|
export default router; |
|
|
|
export default router; |
|
|
|