Expose function name to executing function

This commit is contained in:
Peter Stockings
2025-07-26 20:48:30 +10:00
parent 0ec8986b7a
commit 7d0df16c19

View File

@@ -6,7 +6,7 @@ const States = Object.freeze({
}); });
self.onmessage = async (e) => { self.onmessage = async (e) => {
const { code, request, environment } = e.data; const { code, request, environment, name } = e.data;
const logs: any[] = []; const logs: any[] = [];
const startTime = performance.now(); const startTime = performance.now();
@@ -25,6 +25,7 @@ self.onmessage = async (e) => {
try { try {
// Make the environment object and response helpers available globally. // Make the environment object and response helpers available globally.
(self as any).environment = environment; (self as any).environment = environment;
(self as any).FUNCTION_NAME = name;
(self as any).Response = (body = "", headers = {}, status = 200) => ({ (self as any).Response = (body = "", headers = {}, status = 200) => ({
body, body,
status, status,