Skip to content

Commit 1c02427

Browse files
committed
chore: remove api mode
1 parent 2761b24 commit 1c02427

File tree

3 files changed

+0
-44
lines changed

3 files changed

+0
-44
lines changed

packages/cli/plugin-bff/src/server.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,12 @@ export default (): ServerPlugin => ({
142142
prefix,
143143
httpMethodDecider,
144144
});
145-
const apiMode = apiRouter.getApiMode();
146145

147146
const apiHandlerInfos = await apiRouter.getApiHandlers();
148147
api.updateServerContext({
149148
...appContext,
150149
apiRouter,
151150
apiHandlerInfos,
152-
apiMode,
153151
});
154152
return next(input);
155153
}) as any);

packages/server/bff-core/src/router/constants.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@ import { HttpMethod } from '../types';
22

33
export const AllHttpMethods = Object.values(HttpMethod) as string[];
44

5-
export enum APIMode {
6-
/**
7-
* 框架模式
8-
*/
9-
FARMEWORK = 'framework',
10-
11-
/**
12-
* 函数模式
13-
*/
14-
FUNCTION = 'function',
15-
}
16-
175
export const FRAMEWORK_MODE_LAMBDA_DIR = 'lambda';
186

197
export const FRAMEWORK_MODE_APP_DIR = 'app';

packages/server/bff-core/src/router/index.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { HttpMethodDecider } from '@modern-js/types';
55
import { HttpMethod, OperatorType, TriggerType, httpMethods } from '../types';
66
import { INPUT_PARAMS_DECIDER, debug } from '../utils';
77
import {
8-
APIMode,
98
API_FILE_RULES,
109
FRAMEWORK_MODE_APP_DIR,
1110
FRAMEWORK_MODE_LAMBDA_DIR,
@@ -22,8 +21,6 @@ export * from './types';
2221
export * from './constants';
2322

2423
export class ApiRouter {
25-
private apiMode: APIMode;
26-
2724
private appDir?: string;
2825

2926
private apiDir: string;
@@ -64,7 +61,6 @@ export class ApiRouter {
6461
this.apiDir = apiDir;
6562
this.httpMethodDecider = httpMethodDecider;
6663
this.isBuild = isBuild;
67-
this.apiMode = this.getExactApiMode(apiDir, lambdaDir);
6864
this.lambdaDir = this.getExactLambdaDir(this.apiDir, lambdaDir);
6965
this.existLambdaDir = fs.existsSync(this.lambdaDir);
7066
debug(`apiDir:`, this.apiDir, `lambdaDir:`, this.lambdaDir);
@@ -74,10 +70,6 @@ export class ApiRouter {
7470
return this.existLambdaDir;
7571
}
7672

77-
public getApiMode() {
78-
return this.apiMode;
79-
}
80-
8173
public getLambdaDir() {
8274
return this.lambdaDir;
8375
}
@@ -261,32 +253,10 @@ export class ApiRouter {
261253
}
262254
}
263255

264-
private getExactApiMode = (apiDir: string, lambdaDir?: string): APIMode => {
265-
const exist = this.createExistChecker(apiDir);
266-
const existLambdaDir =
267-
(lambdaDir && fs.pathExistsSync(lambdaDir)) ||
268-
exist(FRAMEWORK_MODE_LAMBDA_DIR);
269-
const existAppDir = exist(FRAMEWORK_MODE_APP_DIR);
270-
const existAppFile = exist('app.ts') || exist('app.js');
271-
272-
if (existLambdaDir || existAppDir || existAppFile) {
273-
return APIMode.FARMEWORK;
274-
}
275-
276-
return APIMode.FUNCTION;
277-
};
278-
279-
private createExistChecker = (base: string) => (target: string) =>
280-
fs.pathExistsSync(path.resolve(base, target));
281-
282256
private getExactLambdaDir = (
283257
apiDir: string,
284258
originLambdaDir?: string,
285259
): string => {
286-
if (this.apiMode === APIMode.FUNCTION) {
287-
return apiDir;
288-
}
289-
290260
return originLambdaDir || path.join(apiDir, FRAMEWORK_MODE_LAMBDA_DIR);
291261
};
292262

0 commit comments

Comments
 (0)