Skip to content

Commit

Permalink
Create helper script to print API routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris Porro committed Jul 1, 2022
1 parent 92fc609 commit 77513ed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions scripts/printRoutes.js
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");
}

0 comments on commit 77513ed

Please sign in to comment.