mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
chore(repo): prune dead code and duplicate abstractions (#3413)
This commit is contained in:
1 parent
c17091768c
commit
c9fdf8fead
2937 files changed
+42233
-176793
No files matched your search
@@ -141,7 +141,7 @@ export class OpenAPIGenerator {
|
||||
continue;
|
||||
}
|
||||
if (!route.responseSchemaName && !route.hasNoContent) {
|
||||
skippedRoutes.push(describeRoute(route, 'no responseSchema and no NoContent()'));
|
||||
skippedRoutes.push(describeRoute(route, 'no responseSchema'));
|
||||
continue;
|
||||
}
|
||||
if (!hasOpenAPIPathTemplate(route.path)) {
|
||||
|
||||
@@ -64,9 +64,6 @@ const RouteMetadata = z.strictObject({
|
||||
.regex(/^[a-z][a-z0-9_]*$/)
|
||||
.optional(),
|
||||
});
|
||||
const RouteOptionsMetadata = RouteMetadata.pick({description: true, responseContentType: true}).extend({
|
||||
description: z.string().min(1),
|
||||
});
|
||||
function isHttpMethod(method: string): method is HttpMethod {
|
||||
return HTTP_METHODS.has(method);
|
||||
}
|
||||
@@ -184,20 +181,12 @@ interface MiddlewareInfo {
|
||||
explicitExperiment?: string;
|
||||
}
|
||||
function extractOpenAPIMetadata(args: ReadonlyArray<Node>, context: MetadataContext): MiddlewareInfo {
|
||||
const [first, summary, responseSchema, options] = args;
|
||||
const [first] = args;
|
||||
if (!first) throw new Error('OpenAPI requires route metadata');
|
||||
if (options !== undefined && !Node.isObjectLiteralExpression(options)) {
|
||||
throw new Error(`OpenAPI options must be an object literal: ${options.getText()}`);
|
||||
if (!Node.isObjectLiteralExpression(first)) {
|
||||
throw new Error(`OpenAPI metadata must be an object literal: ${first.getText()}`);
|
||||
}
|
||||
const value = Node.isObjectLiteralExpression(first)
|
||||
? parseObjectLiteralMetadata(first, context)
|
||||
: {
|
||||
...(options ? RouteOptionsMetadata.parse(parseObjectLiteralMetadata(options, context)) : {}),
|
||||
operationId: resolveMetadataValue(first, context),
|
||||
summary: summary ? resolveMetadataValue(summary, context) : undefined,
|
||||
responseSchema: responseSchema ? extractSchemaName(responseSchema, context) : undefined,
|
||||
tags: [],
|
||||
};
|
||||
const value = parseObjectLiteralMetadata(first, context);
|
||||
const parsed = RouteMetadata.safeParse(value);
|
||||
if (!parsed.success) {
|
||||
throw new Error(`Invalid OpenAPI metadata at line ${first.getStartLineNumber()}`, {cause: parsed.error});
|
||||
@@ -233,10 +222,6 @@ function extractMiddlewareInfo(callExpr: CallExpression, context: MetadataContex
|
||||
switch (name) {
|
||||
case 'RateLimitMiddleware':
|
||||
return {middlewareName: name, rateLimitConfig: args[0]?.getText()};
|
||||
case 'ResponseType':
|
||||
return {middlewareName: name, responseSchemaName: args[0]?.getText()};
|
||||
case 'NoContent':
|
||||
return {middlewareName: name, hasNoContent: true};
|
||||
case 'OpenAPI':
|
||||
return extractOpenAPIMetadata(args, context);
|
||||
case 'requireOAuth2Scope':
|
||||
|
||||
Reference in new issue
Block a user