fix: data template middleware in data source (#4378)

* fix: data template middleware in data source

* fix: typo
This commit is contained in:
ChengLei Shao 2024-05-17 23:14:26 +08:00 committed by GitHub
parent 3d000d395e
commit 2ee67e15e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 10 deletions

View File

@ -58,6 +58,8 @@ import packageJson from '../package.json';
import { MainDataSource } from './main-data-source';
import validateFilterParams from './middlewares/validate-filter-params';
import path from 'path';
import { parseVariables } from './middlewares';
import { dataTemplate } from './middlewares/data-template';
export type PluginType = string | typeof Plugin;
export type PluginConfiguration = PluginType | [PluginType, any];
@ -1111,6 +1113,12 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
this._dataSourceManager.use(this._authManager.middleware(), { tag: 'auth' });
this._dataSourceManager.use(validateFilterParams, { tag: 'validate-filter-params', before: ['auth'] });
this._dataSourceManager.use(parseVariables, {
group: 'parseVariables',
after: 'acl',
});
this._dataSourceManager.use(dataTemplate, { group: 'dataTemplate', after: 'acl' });
this._locales = new Locale(createAppProxy(this));
if (options.perfHooks) {

View File

@ -8,8 +8,6 @@
*/
import { DataSourceOptions, SequelizeDataSource } from '@nocobase/data-source-manager';
import { parseVariables } from './middlewares';
import { dateTemplate } from './middlewares/data-template';
export class MainDataSource extends SequelizeDataSource {
init(options: DataSourceOptions = {}) {
@ -30,12 +28,5 @@ export class MainDataSource extends SequelizeDataSource {
if (options.useACL !== false) {
this.resourceManager.use(this.acl.middleware(), { group: 'acl', after: 'auth' });
}
this.resourceManager.use(parseVariables, {
group: 'parseVariables',
after: 'acl',
});
this.resourceManager.use(dateTemplate, { group: 'dateTemplate', after: 'acl' });
}
}

View File

@ -10,7 +10,7 @@
import { Context } from '@nocobase/actions';
import { Collection } from '@nocobase/database';
export const dateTemplate = async (ctx: Context, next) => {
export const dataTemplate = async (ctx: Context, next) => {
const { resourceName, actionName } = ctx.action;
const { isTemplate, fields } = ctx.action.params;