forked from portable-cto/airtable-proxy-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create helper script to print API routes
- Loading branch information
Floris Porro
committed
Jul 1, 2022
1 parent
92fc609
commit 77513ed
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { config, routes } from "../config.js"; | ||
|
||
const methods = { | ||
list: "GET", | ||
create: "POST", | ||
read: "GET", | ||
update: "PATCH", | ||
delete: "DELETE", | ||
}; | ||
|
||
for (const route of routes) { | ||
console.log(`# ${route.name}`); | ||
console.log("\n"); | ||
|
||
for (const [method, properties] of Object.entries(route.methods)) { | ||
let path = config.apiBaseUrl + route.path; | ||
if (method !== "list") { | ||
path += "/:id"; | ||
} | ||
console.log(`## ${methods[method]} ${path}`); | ||
|
||
if (properties.whitelist) { | ||
console.log("Whitelist:" + JSON.stringify(properties.whitelist)); | ||
} | ||
if (properties.blacklist) { | ||
console.log("Blacklist:" + JSON.stringify(properties.blacklist)); | ||
} | ||
} | ||
console.log("\n"); | ||
} |