Last active
October 15, 2022 05:06
-
-
Save rootasjey/f88e4df08b0646a41cec10cfb4f63bcc to your computer and use it in GitHub Desktop.
Revisions
-
rootasjey revised this gist
Oct 15, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export const fetch = functions } // Check this helper function in its dedicated gist. // // [firebase_functions_helper_post_acl.ts](https://gist.github.com/rootasjey/6b8594cd4da10822c5029a6997f1b8c6) await checkAccessControl({projectId, jwt}); // Retrieve content (access control OK) -
rootasjey revised this gist
Oct 15, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export const fetch = functions ); } // Check this helper function in its dedicated gist. await checkAccessControl({projectId, jwt}); // Retrieve content (access control OK) -
rootasjey created this gist
Oct 15, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ /** * Retrieve a project's content in markdown format * (with accessibility check). */ export const fetch = functions .region(cloudRegions.eu) .https .onCall(async (data) => { const projectId: string = data.projectId; /** Used if the project is a draft or restricted to some members. */ const jwt: string = data.jwt; if (!projectId) { throw new functions.https.HttpsError( "invalid-argument", `The function must be called with one (string) argument "projectId" which is the project to fetch.`, ); } await checkAccessControl({projectId, jwt}); // Retrieve content (access control OK) const projectFile = storage .bucket() .file(`blog/projects/${projectId}/post.md`); let projectContent = ""; const stream = projectFile.createReadStream(); stream.on("data", (chunck) => { projectContent = projectContent.concat(chunck.toString()); }); await new Promise((fulfill) => stream.on("end", fulfill)); stream.destroy(); return {project: projectContent}; });