MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / getMatchingAction

Function getMatchingAction

pages/api/mock/[...slug].ts:76–104  ·  view source on GitHub ↗
(
  org_id: number,
  actions: Action[],
  method: RequestMethod,
  slug: string[],
)

Source from the content-addressed store, hash-verified

74}
75
76export function getMatchingAction(
77 org_id: number,
78 actions: Action[],
79 method: RequestMethod,
80 slug: string[],
81): Action | null {
82 // Note: Assumes you have already filtered by request method
83
84 const slugString = "/" + slug.join("/");
85
86 let matches = actions.filter((action) => {
87 return action.path && slugMatchesPath(action.path, slugString);
88 });
89
90 if (matches.length === 0) {
91 console.log(
92 `Could not match slug "${slugString}" with method "${method}" to any action in the database for organisation "${org_id}"`,
93 );
94 return null;
95 }
96
97 if (matches.length > 1) matches = processMultipleMatches(matches, slug);
98
99 console.log(
100 `Successfully matched slug "${slugString}" to action with path "${matches[0].path}"`,
101 );
102
103 return matches[0];
104}
105
106export function getPathParameters(
107 path: string,

Callers 2

slug.test.tsFile · 0.90
handlerFunction · 0.85

Calls 2

slugMatchesPathFunction · 0.85
processMultipleMatchesFunction · 0.85

Tested by

no test coverage detected