mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
fix: data template middleware in data source (#4378)
* fix: data template middleware in data source * fix: typo
This commit is contained in:
parent
3d000d395e
commit
2ee67e15e8
@ -58,6 +58,8 @@ import packageJson from '../package.json';
|
|||||||
import { MainDataSource } from './main-data-source';
|
import { MainDataSource } from './main-data-source';
|
||||||
import validateFilterParams from './middlewares/validate-filter-params';
|
import validateFilterParams from './middlewares/validate-filter-params';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { parseVariables } from './middlewares';
|
||||||
|
import { dataTemplate } from './middlewares/data-template';
|
||||||
|
|
||||||
export type PluginType = string | typeof Plugin;
|
export type PluginType = string | typeof Plugin;
|
||||||
export type PluginConfiguration = PluginType | [PluginType, any];
|
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(this._authManager.middleware(), { tag: 'auth' });
|
||||||
this._dataSourceManager.use(validateFilterParams, { tag: 'validate-filter-params', before: ['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));
|
this._locales = new Locale(createAppProxy(this));
|
||||||
|
|
||||||
if (options.perfHooks) {
|
if (options.perfHooks) {
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { DataSourceOptions, SequelizeDataSource } from '@nocobase/data-source-manager';
|
import { DataSourceOptions, SequelizeDataSource } from '@nocobase/data-source-manager';
|
||||||
import { parseVariables } from './middlewares';
|
|
||||||
import { dateTemplate } from './middlewares/data-template';
|
|
||||||
|
|
||||||
export class MainDataSource extends SequelizeDataSource {
|
export class MainDataSource extends SequelizeDataSource {
|
||||||
init(options: DataSourceOptions = {}) {
|
init(options: DataSourceOptions = {}) {
|
||||||
@ -30,12 +28,5 @@ export class MainDataSource extends SequelizeDataSource {
|
|||||||
if (options.useACL !== false) {
|
if (options.useACL !== false) {
|
||||||
this.resourceManager.use(this.acl.middleware(), { group: 'acl', after: 'auth' });
|
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' });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
import { Context } from '@nocobase/actions';
|
import { Context } from '@nocobase/actions';
|
||||||
import { Collection } from '@nocobase/database';
|
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 { resourceName, actionName } = ctx.action;
|
||||||
const { isTemplate, fields } = ctx.action.params;
|
const { isTemplate, fields } = ctx.action.params;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user