2020-11-11 15:23:39 +08:00
|
|
|
import path from 'path';
|
2020-12-23 12:46:13 +08:00
|
|
|
import Database from '@nocobase/database';
|
2020-11-11 15:23:39 +08:00
|
|
|
import Resourcer from '@nocobase/resourcer';
|
|
|
|
|
2020-12-19 08:45:19 +08:00
|
|
|
import {
|
|
|
|
action as uploadAction,
|
|
|
|
middleware as uploadMiddleware,
|
|
|
|
} from './actions/upload';
|
2020-12-23 12:46:13 +08:00
|
|
|
import {
|
|
|
|
middleware as localMiddleware,
|
|
|
|
} from './storages/local';
|
2020-12-19 08:45:19 +08:00
|
|
|
|
2020-12-23 12:46:13 +08:00
|
|
|
export default async function () {
|
2020-11-11 15:23:39 +08:00
|
|
|
const database: Database = this.database;
|
|
|
|
const resourcer: Resourcer = this.resourcer;
|
|
|
|
|
2020-11-11 20:57:18 +08:00
|
|
|
database.import({
|
2020-11-11 15:23:39 +08:00
|
|
|
directory: path.resolve(__dirname, 'collections'),
|
|
|
|
});
|
2020-12-19 08:45:19 +08:00
|
|
|
|
|
|
|
// 暂时中间件只能通过 use 加进来
|
|
|
|
resourcer.use(uploadMiddleware);
|
|
|
|
resourcer.registerActionHandler('upload', uploadAction);
|
2020-12-23 12:46:13 +08:00
|
|
|
localMiddleware(this);
|
2020-11-11 15:23:39 +08:00
|
|
|
}
|