tachybase_todo/packages/core/actions/src/index.ts

42 lines
769 B
TypeScript
Raw Normal View History

import Koa from 'koa';
2021-12-06 21:23:34 +08:00
import { Database } from '@nocobase/database';
import { Action } from '@nocobase/resourcer';
import { Cache } from '@nocobase/cache';
import lodash from 'lodash';
import * as actions from './actions';
export * as utils from './utils';
export type Next = () => Promise<any>;
export interface Context extends Koa.Context {
db: Database;
cache: Cache;
action: Action;
body: any;
app: any;
2021-12-06 21:23:34 +08:00
[key: string]: any;
}
export function registerActions(api: any) {
api.actions(
lodash.pick(actions, [
'add',
'create',
'destroy',
'get',
'list',
'remove',
'set',
'toggle',
'update',
'move',
'firstOrCreate',
'updateOrCreate',
]),
);
}
export default actions;