feat(backend): add sync at backend

This commit is contained in:
DCsunset 2020-10-29 20:57:51 +08:00
parent 98b4e8be81
commit b62255f928
2 changed files with 15 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import * as logger from 'koa-logger';
import * as qs from 'koa-qs';
import tasksRouter from './tasks';
import syncRouter from './sync';
import { TaskError } from 'taskwarrior-lib';
const app = new Koa();
@ -28,6 +29,7 @@ app.use(async (ctx, next) => {
const router = new Router();
router.use('/tasks', tasksRouter.routes());
router.use('/sync', syncRouter.routes());
app.use(router.routes());
app.use(router.allowedMethods());

13
backend/src/sync.ts Normal file
View file

@ -0,0 +1,13 @@
import * as Router from '@koa/router';
import taskwarrior from './taskwarrior';
const router = new Router();
router.post('/', async ctx => {
const msg = taskwarrior.executeCommand('sync');
console.log(msg);
ctx.status = 200;
});
export default router;