@intuned/runtime-dev 1.0.4-stuck.1 → 1.0.6-cli-auth.0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/InterfaceTemplate/utils.ts +53 -31
- package/bin/cli-build +3 -0
- package/bin/create-auth-session +3 -0
- package/bin/deploy +3 -0
- package/bin/init +3 -0
- package/bin/run-api +3 -0
- package/dist/commands/api/run.js +2 -2
- package/dist/commands/auth-sessions/load.js +1 -1
- package/dist/commands/auth-sessions/run-check.js +2 -2
- package/dist/commands/auth-sessions/run-create.js +2 -2
- package/dist/commands/browser/save-state.js +1 -1
- package/dist/commands/browser/start-browser.js +1 -1
- package/dist/commands/build.js +4 -4
- package/dist/commands/cli-auth-sessions/check.d.ts +0 -0
- package/dist/commands/cli-auth-sessions/check.js +1 -0
- package/dist/commands/cli-auth-sessions/create.d.ts +2 -0
- package/dist/commands/cli-auth-sessions/create.js +28 -0
- package/dist/commands/cli-auth-sessions/utils.d.ts +4 -0
- package/dist/commands/cli-auth-sessions/utils.js +55 -0
- package/dist/commands/cli-build/cli-build.d.ts +2 -0
- package/dist/commands/cli-build/cli-build.js +20 -0
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +3 -3
- package/dist/commands/common/getFirstLineNumber.test.js +2 -2
- package/dist/commands/common/projectExclusions.d.ts +2 -0
- package/dist/commands/common/projectExclusions.js +8 -0
- package/dist/commands/common/tsNodeImport.d.ts +2 -1
- package/dist/commands/common/tsNodeImport.js +20 -6
- package/dist/commands/common/utils/fileUtils.js +2 -2
- package/dist/commands/common/utils/settings.js +1 -1
- package/dist/commands/common/utils/template.d.ts +1 -1
- package/dist/commands/common/utils/template.js +1 -1
- package/dist/commands/deploy/deploy.d.ts +2 -0
- package/dist/commands/deploy/deploy.js +47 -0
- package/dist/commands/deploy/utils.d.ts +16 -0
- package/dist/commands/deploy/utils.js +350 -0
- package/dist/commands/init/init.d.ts +2 -0
- package/dist/commands/init/init.js +22 -0
- package/dist/commands/init/utils.d.ts +9 -0
- package/dist/commands/init/utils.js +179 -0
- package/dist/commands/interface/run.js +141 -94
- package/dist/commands/run-api-cli/run-api.d.ts +2 -0
- package/dist/commands/run-api-cli/run-api.js +48 -0
- package/dist/commands/run-api-cli/utils.d.ts +10 -0
- package/dist/commands/run-api-cli/utils.js +98 -0
- package/dist/commands/ts-check.js +2 -2
- package/dist/common/Logger/Logger/index.js +1 -1
- package/dist/common/Logger/index.js +1 -1
- package/dist/common/asyncLocalStorage/index.d.ts +1 -1
- package/dist/common/asyncLocalStorage/index.js +2 -2
- package/dist/common/cli/cliReadme.d.ts +1 -0
- package/dist/common/cli/cliReadme.js +69 -0
- package/dist/common/cli/constants.d.ts +24 -0
- package/dist/common/cli/constants.js +30 -0
- package/dist/common/cli/types.d.ts +52 -0
- package/dist/common/cli/types.js +7 -0
- package/dist/common/cli/utils.d.ts +6 -0
- package/dist/common/cli/utils.js +35 -0
- package/dist/common/contextStorageStateHelpers.d.ts +20 -13
- package/dist/common/contextStorageStateHelpers.js +69 -42
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +5 -5
- package/dist/common/jwtTokenManager.js +2 -2
- package/dist/common/runApi/errors.d.ts +0 -11
- package/dist/common/runApi/errors.js +2 -41
- package/dist/common/runApi/index.d.ts +2 -1
- package/dist/common/runApi/index.js +11 -4
- package/dist/common/runApi/types.d.ts +82 -76
- package/dist/common/runApi/types.js +1 -1
- package/dist/common/settingsSchema.js +1 -1
- package/dist/common/telemetry.js +1 -1
- package/package.json +14 -6
- package/WebTemplate/accessKeyHelpers.ts +0 -28
- package/WebTemplate/api.ts +0 -139
- package/WebTemplate/app.ts +0 -18
- package/WebTemplate/controllers/async.ts +0 -142
- package/WebTemplate/controllers/authSessions/check.ts +0 -61
- package/WebTemplate/controllers/authSessions/create.ts +0 -101
- package/WebTemplate/controllers/authSessions/index.ts +0 -41
- package/WebTemplate/controllers/authSessions/killOperation.ts +0 -35
- package/WebTemplate/controllers/authSessions/resumeOperation.ts +0 -56
- package/WebTemplate/controllers/authSessions/store.ts +0 -19
- package/WebTemplate/controllers/controllers.ts +0 -73
- package/WebTemplate/controllers/runApi/helpers.ts +0 -128
- package/WebTemplate/controllers/runApi/index.ts +0 -68
- package/WebTemplate/controllers/runApi/types.ts +0 -13
- package/WebTemplate/controllers/traces.ts +0 -151
- package/WebTemplate/features.ts +0 -8
- package/WebTemplate/headers.ts +0 -6
- package/WebTemplate/index.playwright.ts +0 -47
- package/WebTemplate/index.vanilla.ts +0 -26
- package/WebTemplate/jobs.ts +0 -356
- package/WebTemplate/shutdown.ts +0 -64
- package/WebTemplate/utils.ts +0 -257
- package/WebTemplate.zip +0 -0
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTraceFilePath,
|
|
3
|
-
importModule,
|
|
4
|
-
waitWithExtendableTimeout,
|
|
5
|
-
} from "../../utils";
|
|
6
|
-
import * as fs from "fs-extra";
|
|
7
|
-
import { getExecutionContext } from "@intuned/runtime";
|
|
8
|
-
import { backendFunctionsTokenManager } from "@intuned/runtime/dist/common/jwtTokenManager";
|
|
9
|
-
import { RunBody } from "./types";
|
|
10
|
-
import { runApi as runApiInternal } from "@intuned/runtime/dist/common/runApi";
|
|
11
|
-
|
|
12
|
-
export async function runApi({
|
|
13
|
-
session,
|
|
14
|
-
params,
|
|
15
|
-
proxy,
|
|
16
|
-
functionsToken,
|
|
17
|
-
runId,
|
|
18
|
-
attemptNumber,
|
|
19
|
-
functionName,
|
|
20
|
-
shouldSaveTrace,
|
|
21
|
-
headless = true,
|
|
22
|
-
}: RunBody & {
|
|
23
|
-
runId: string;
|
|
24
|
-
attemptNumber: string | undefined;
|
|
25
|
-
functionName: string;
|
|
26
|
-
shouldSaveTrace: boolean;
|
|
27
|
-
headless?: boolean;
|
|
28
|
-
}): Promise<{
|
|
29
|
-
status: number;
|
|
30
|
-
body: any;
|
|
31
|
-
}> {
|
|
32
|
-
const isAuthSessionEnabled = (await fs.readJSON("./Intuned.json"))
|
|
33
|
-
.authSessions?.enabled;
|
|
34
|
-
|
|
35
|
-
if (!runId) {
|
|
36
|
-
return {
|
|
37
|
-
status: 400,
|
|
38
|
-
body: {
|
|
39
|
-
error: "runId header not provided",
|
|
40
|
-
message: "Please add provide run id to header",
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
backendFunctionsTokenManager.token = functionsToken;
|
|
46
|
-
|
|
47
|
-
// handle timeout
|
|
48
|
-
const requestTimeout = +(process.env.REQUEST_TIMEOUT ?? 600) * 1000;
|
|
49
|
-
getExecutionContext()!.timeoutInfo = {
|
|
50
|
-
...(getExecutionContext()?.timeoutInfo ?? {}),
|
|
51
|
-
timeoutDuration: requestTimeout,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
async function handleTimeout() {
|
|
55
|
-
console.log("timeout triggered");
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
status: 508,
|
|
59
|
-
body: {
|
|
60
|
-
error: "TimeoutError",
|
|
61
|
-
message: "The request timed out",
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const abortController = new AbortController();
|
|
67
|
-
|
|
68
|
-
backendFunctionsTokenManager.token = functionsToken;
|
|
69
|
-
const resultWithTimeout = await waitWithExtendableTimeout({
|
|
70
|
-
promise: runApiInternal({
|
|
71
|
-
automationFunction: {
|
|
72
|
-
name: `api/${functionName}`,
|
|
73
|
-
params,
|
|
74
|
-
},
|
|
75
|
-
auth: isAuthSessionEnabled
|
|
76
|
-
? {
|
|
77
|
-
session: {
|
|
78
|
-
type: "state",
|
|
79
|
-
state: session,
|
|
80
|
-
},
|
|
81
|
-
runCheck: isAuthSessionEnabled,
|
|
82
|
-
}
|
|
83
|
-
: undefined,
|
|
84
|
-
runOptions: {
|
|
85
|
-
environment: "standalone",
|
|
86
|
-
headless,
|
|
87
|
-
proxy,
|
|
88
|
-
},
|
|
89
|
-
tracing: shouldSaveTrace
|
|
90
|
-
? {
|
|
91
|
-
enabled: true,
|
|
92
|
-
filePath: getTraceFilePath(runId, attemptNumber),
|
|
93
|
-
}
|
|
94
|
-
: { enabled: false },
|
|
95
|
-
abortSignal: abortController.signal,
|
|
96
|
-
importFunction: importModule,
|
|
97
|
-
}),
|
|
98
|
-
initialTimeout: requestTimeout,
|
|
99
|
-
abortController,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
if (resultWithTimeout.timedOut === true) {
|
|
103
|
-
return await handleTimeout();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const { result } = resultWithTimeout;
|
|
107
|
-
|
|
108
|
-
if (result.isErr()) {
|
|
109
|
-
if (result.error.code === "AbortedError") {
|
|
110
|
-
return await handleTimeout();
|
|
111
|
-
}
|
|
112
|
-
return result.error.apiResponse;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
status: 200,
|
|
117
|
-
body: {
|
|
118
|
-
status: 200,
|
|
119
|
-
result: result.value.result,
|
|
120
|
-
payloadToAppend: result.value.extendedPayloads?.map(
|
|
121
|
-
({ api, parameters }) => ({
|
|
122
|
-
apiName: api,
|
|
123
|
-
parameters,
|
|
124
|
-
})
|
|
125
|
-
),
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Handler } from "@tinyhttp/app";
|
|
2
|
-
import { RUN_ID_HEADER, ATTEMPT_NUMBER_HEADER } from "../../headers";
|
|
3
|
-
import { runApi } from "./helpers";
|
|
4
|
-
import { AsyncRunEndpointController, isHeadless } from "../../utils";
|
|
5
|
-
import { makeEndpointControllers } from "../controllers";
|
|
6
|
-
export { runApi } from "./helpers";
|
|
7
|
-
|
|
8
|
-
export interface Proxy {
|
|
9
|
-
server: string;
|
|
10
|
-
username: string;
|
|
11
|
-
password: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface RunBody {
|
|
15
|
-
session: any;
|
|
16
|
-
params?: object;
|
|
17
|
-
proxy?: Proxy;
|
|
18
|
-
executionContext: any;
|
|
19
|
-
functionsToken: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const { sync: runApiController, async: runApiAsyncController } =
|
|
23
|
-
makeEndpointControllers({
|
|
24
|
-
requestId: (req) =>
|
|
25
|
-
`runApi ${req.headers[RUN_ID_HEADER]} (${req.headers[ATTEMPT_NUMBER_HEADER]})`,
|
|
26
|
-
parameters: (req) => {
|
|
27
|
-
// e.g. /api/run/folder1/api should be folder1/api
|
|
28
|
-
const functionName = req.params.wild
|
|
29
|
-
.split("/")
|
|
30
|
-
// filter(Boolean) should remove empty strings in case of a trailing slash
|
|
31
|
-
.filter(Boolean)
|
|
32
|
-
.join("/");
|
|
33
|
-
|
|
34
|
-
const { session, params, proxy, executionContext, functionsToken } =
|
|
35
|
-
req.body as RunBody;
|
|
36
|
-
const runId = req.headers[RUN_ID_HEADER] as string;
|
|
37
|
-
const attemptNumber = req.headers[ATTEMPT_NUMBER_HEADER] as
|
|
38
|
-
| string
|
|
39
|
-
| undefined;
|
|
40
|
-
const shouldSaveTrace = req.query.saveTrace === "true";
|
|
41
|
-
const headless = isHeadless();
|
|
42
|
-
const result: Parameters<typeof runApi> = [
|
|
43
|
-
{
|
|
44
|
-
session,
|
|
45
|
-
params,
|
|
46
|
-
proxy,
|
|
47
|
-
executionContext,
|
|
48
|
-
functionsToken,
|
|
49
|
-
runId,
|
|
50
|
-
attemptNumber,
|
|
51
|
-
functionName,
|
|
52
|
-
shouldSaveTrace,
|
|
53
|
-
headless,
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
return result;
|
|
57
|
-
},
|
|
58
|
-
handler: async (parameters: Parameters<typeof runApi>[0]) => {
|
|
59
|
-
const { status, body } = await runApi(parameters);
|
|
60
|
-
return { status, body };
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export const getActiveAsyncEndpointController: Handler = async (req, res) => {
|
|
65
|
-
res
|
|
66
|
-
.status(200)
|
|
67
|
-
.json({ count: AsyncRunEndpointController.activeRequestsCount });
|
|
68
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { getTraceFilePath } from "../utils";
|
|
2
|
-
import { pathExists, remove, createReadStream, stat } from "fs-extra";
|
|
3
|
-
import fetch from "node-fetch";
|
|
4
|
-
import { Handler } from "@tinyhttp/app";
|
|
5
|
-
import { ok, err } from "neverthrow";
|
|
6
|
-
|
|
7
|
-
export async function uploadTrace({
|
|
8
|
-
runId,
|
|
9
|
-
attemptNumber,
|
|
10
|
-
signedUrl,
|
|
11
|
-
}: {
|
|
12
|
-
runId: string;
|
|
13
|
-
attemptNumber?: string;
|
|
14
|
-
signedUrl: string;
|
|
15
|
-
}) {
|
|
16
|
-
const traceFilePath = getTraceFilePath(
|
|
17
|
-
runId,
|
|
18
|
-
attemptNumber as string | undefined
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
if (!(await pathExists(traceFilePath))) {
|
|
22
|
-
return err({
|
|
23
|
-
message: "Trace file not found",
|
|
24
|
-
error: "Not found",
|
|
25
|
-
errorCode: "trace_file_not_found" as const,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const fileSize = (await stat(traceFilePath)).size;
|
|
30
|
-
const file = createReadStream(traceFilePath);
|
|
31
|
-
|
|
32
|
-
const response = await fetch(signedUrl, {
|
|
33
|
-
method: "PUT",
|
|
34
|
-
headers: {
|
|
35
|
-
"Content-Length": fileSize.toString(),
|
|
36
|
-
},
|
|
37
|
-
body: file,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (!response.ok) {
|
|
41
|
-
return err({
|
|
42
|
-
message: `Upload trace failed with status code ${response.status}`,
|
|
43
|
-
error: "Upload trace failed",
|
|
44
|
-
errorCode: "upload_trace_failed" as const,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return ok({
|
|
49
|
-
traceName: `${runId}.zip`,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function deleteTrace({
|
|
54
|
-
runId,
|
|
55
|
-
attemptNumber,
|
|
56
|
-
}: {
|
|
57
|
-
runId: string;
|
|
58
|
-
attemptNumber?: string;
|
|
59
|
-
}) {
|
|
60
|
-
const traceFilePath = getTraceFilePath(
|
|
61
|
-
runId,
|
|
62
|
-
attemptNumber as string | undefined
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
if (!(await pathExists(traceFilePath))) {
|
|
66
|
-
return err({
|
|
67
|
-
message: "Trace file not found",
|
|
68
|
-
error: "Not found",
|
|
69
|
-
errorCode: "trace_file_not_found" as const,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
await remove(traceFilePath);
|
|
75
|
-
return ok(undefined);
|
|
76
|
-
} catch (error: any) {
|
|
77
|
-
return err({
|
|
78
|
-
message: `Delete trace file failed ${runId}`,
|
|
79
|
-
error: "Delete trace failed",
|
|
80
|
-
errorCode: "delete_trace_failed" as const,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const uploadTraceController: Handler = async (req, res) => {
|
|
86
|
-
const { runId } = req.params;
|
|
87
|
-
const { attemptNumber } = req.query;
|
|
88
|
-
|
|
89
|
-
const signedUrl = req.body.signedUrl as string;
|
|
90
|
-
if (!runId) {
|
|
91
|
-
return res.status(400).json({
|
|
92
|
-
error: "runId not provided",
|
|
93
|
-
message: "Please add provide run id",
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (!signedUrl) {
|
|
98
|
-
return res.status(400).json({
|
|
99
|
-
error: "signedUrl not provided",
|
|
100
|
-
message: "Please add provide signedUrl",
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const uploadTraceResult = await uploadTrace({
|
|
105
|
-
runId,
|
|
106
|
-
attemptNumber: attemptNumber as string | undefined,
|
|
107
|
-
signedUrl,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (uploadTraceResult.isOk()) {
|
|
111
|
-
return res.status(200).json({
|
|
112
|
-
result: uploadTraceResult.value,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const error = uploadTraceResult.error;
|
|
117
|
-
if (error.errorCode === "trace_file_not_found") {
|
|
118
|
-
return res.status(404).json(error);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return res.status(500).json(error);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const deleteTraceController: Handler = async (req, res) => {
|
|
125
|
-
const { runId } = req.params;
|
|
126
|
-
const { attemptNumber } = req.query;
|
|
127
|
-
|
|
128
|
-
if (!runId) {
|
|
129
|
-
return res.status(400).json({
|
|
130
|
-
error: "runId not provided",
|
|
131
|
-
message: "Please add provide run id",
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const deleteTraceResult = await deleteTrace({
|
|
136
|
-
runId,
|
|
137
|
-
attemptNumber: attemptNumber as string | undefined,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
if (deleteTraceResult.isOk()) {
|
|
141
|
-
return res.status(204).send("");
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const error = deleteTraceResult.error;
|
|
145
|
-
|
|
146
|
-
if (error.errorCode === "trace_file_not_found") {
|
|
147
|
-
return res.status(404).json(error);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return res.status(500).json(error);
|
|
151
|
-
};
|
package/WebTemplate/features.ts
DELETED
package/WebTemplate/headers.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const RUN_ID_HEADER = "x-run-id";
|
|
2
|
-
export const JOB_ID_HEADER = "x-job-id";
|
|
3
|
-
export const JOB_RUN_ID_HEADER = "x-job-run-id";
|
|
4
|
-
export const QUEUE_ID_HEADER = "x-queue-id";
|
|
5
|
-
export const ATTEMPT_NUMBER_HEADER = "x-attempt-number";
|
|
6
|
-
export const SHOULD_SHUTDOWN_HEADER = "x-should-shutdown";
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
initializeAppInsights,
|
|
3
|
-
getTelemetryClient,
|
|
4
|
-
} from "@intuned/runtime/dist/common/telemetry";
|
|
5
|
-
import { getExecutionContext } from "@intuned/runtime";
|
|
6
|
-
import { app } from "./app";
|
|
7
|
-
import { RUN_ID_HEADER } from "./headers";
|
|
8
|
-
import { ShutdownController } from "./shutdown";
|
|
9
|
-
|
|
10
|
-
const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
|
11
|
-
|
|
12
|
-
initializeAppInsights();
|
|
13
|
-
|
|
14
|
-
app.use((req, res, next) => {
|
|
15
|
-
// Cleanup after the response is sent
|
|
16
|
-
res.on("finish", () => {
|
|
17
|
-
console.log("finished", req.headers[RUN_ID_HEADER]);
|
|
18
|
-
void ShutdownController.instance.checkForShutdown();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
next();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export * from "./api";
|
|
25
|
-
export * from "./jobs";
|
|
26
|
-
|
|
27
|
-
const server = app.listen(port, () => {
|
|
28
|
-
// when deployed on flyio, the server will be turned on and
|
|
29
|
-
// will shutdown after the specified time in TIME_TO_SHUTDOWN env variable
|
|
30
|
-
ShutdownController.initialize(server);
|
|
31
|
-
void ShutdownController.instance.checkForShutdown();
|
|
32
|
-
console.log(`Server is running on port ${port}`);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
process.on("unhandledRejection", (reason, promise) => {
|
|
36
|
-
const telemetryClient = getTelemetryClient();
|
|
37
|
-
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
38
|
-
const context = getExecutionContext();
|
|
39
|
-
telemetryClient?.trackEvent({
|
|
40
|
-
name: "UNHANDLED_REJECTION",
|
|
41
|
-
properties: {
|
|
42
|
-
runId: context?.runId,
|
|
43
|
-
promise,
|
|
44
|
-
reason,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { App } from "@tinyhttp/app";
|
|
2
|
-
import { json as parser } from "milliparsec";
|
|
3
|
-
import { accessKeyValidatorMiddleware } from "./accessKeyHelpers";
|
|
4
|
-
|
|
5
|
-
const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
|
6
|
-
const app = new App();
|
|
7
|
-
|
|
8
|
-
app.use("/", parser());
|
|
9
|
-
|
|
10
|
-
app.post("/api/run/*", async (req, res) => {
|
|
11
|
-
return res.status(502).json({ message: "Not implemented" });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
app.get("/api/health", async (req, res) => {
|
|
15
|
-
res.status(200).json({ status: "ok" });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
app.use(accessKeyValidatorMiddleware);
|
|
19
|
-
|
|
20
|
-
app.get("/protected/health", async (req, res) => {
|
|
21
|
-
res.status(200).json({ status: "ok" });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
app.listen(port, () => {
|
|
25
|
-
console.log(`Server is running on port ${port}`);
|
|
26
|
-
});
|