Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/extractors/fastapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const fastapi: Extractor = {
const funcParams = m[6]!;
const line = lines.lineAt(m.index);

if (httpMethod === "WEBSOCKET") httpMethod = "WS";
const isWebSocket = httpMethod === "WEBSOCKET";
if (isWebSocket) httpMethod = "WS";

const prefix = routerPrefixes[varName] ?? "";
const fullPath = normalizePath(prefix + routePath);
Expand All @@ -83,6 +84,7 @@ export const fastapi: Extractor = {
endpoints.push(
endpoint({
method: httpMethod,
kind: isWebSocket ? "websocket" : "api",
path: fullPath,
handler: funcName,
file: rel,
Expand Down
1 change: 1 addition & 0 deletions src/extractors/server-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export const serverActions: Extractor = {
endpoints.push(
endpoint({
method: "ACTION",
kind: "action",
path: `/${moduleName}/${exp.name}`,
handler: exp.name,
file: rel,
Expand Down
2 changes: 2 additions & 0 deletions src/format-impact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export function formatImpactJson(result: ImpactResult): string {
affected: result.affected.map((a) => {
const obj: Record<string, unknown> = {
method: a.endpoint.method,
kind: a.endpoint.kind,
path: a.endpoint.path,
handler: a.endpoint.handler,
file: a.endpoint.file,
Expand Down Expand Up @@ -151,6 +152,7 @@ export function formatImpactNdjson(result: ImpactResult): string {
for (const a of result.affected) {
const obj: Record<string, unknown> = {
method: a.endpoint.method,
kind: a.endpoint.kind,
path: a.endpoint.path,
handler: a.endpoint.handler,
file: a.endpoint.file,
Expand Down
2 changes: 2 additions & 0 deletions src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export function formatJson(result: MapResult, options?: FormatOptions): string {
endpoints: endpoints.all.map((e) => {
const obj: Record<string, unknown> = {
method: e.method,
kind: e.kind,
path: e.path,
handler: e.handler,
file: e.file,
Expand Down Expand Up @@ -263,6 +264,7 @@ export function formatNdjson(
for (const e of endpoints) {
const obj: Record<string, unknown> = {
method: e.method,
kind: e.kind,
path: e.path,
handler: e.handler,
file: e.file,
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type {
AffectedEndpoint,
DiffHunk,
EndpointInfo,
EndpointKind,
FunctionDef,
FrameworkId,
HttpMethod,
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type HttpMethod =
| "WS"
| "ACTION";

export type EndpointKind = "api" | "page" | "action" | "websocket";

export type ServiceType =
| "nextjs"
| "lambda"
Expand All @@ -37,6 +39,7 @@ export interface ServiceInfo {

export interface EndpointInfo {
method: HttpMethod;
kind: EndpointKind;
path: string;
handler: string;
file: string;
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
EndpointInfo,
EndpointKind,
FrameworkId,
HttpMethod,
ParamInfo,
Expand Down Expand Up @@ -100,6 +101,7 @@ export function endpoint(e: {
file: string;
line: number;
framework: FrameworkId;
kind?: EndpointKind;
params?: ParamInfo[];
auth?: string[];
service?: string;
Expand All @@ -108,6 +110,7 @@ export function endpoint(e: {
}): EndpointInfo {
const ep: EndpointInfo = {
method: e.method as HttpMethod,
kind: e.kind ?? "api",
path: e.path,
handler: e.handler,
file: e.file,
Expand Down
Loading