-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparameters.js
More file actions
31 lines (26 loc) · 819 Bytes
/
parameters.js
File metadata and controls
31 lines (26 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module.exports = {
parameters: (body) => {
const regex = /Language:\s*(.*?)\s*Input:\s*([\s\S]+)/s;
const matches = body.match(regex);
if (!matches) {
return {
status: 400,
message: "language and input not present",
};
}
const [, language, Input] = matches;
const supportedLanguages = ["java", "py", "cpp", "c", "go", "cs", "js"];
if (!supportedLanguages.includes(language)) {
return {
status: 400,
message: "Language not found. Please choose a valid programming language.The code should be in following languages-java, py, cpp, c, go, cs, js",
};
}
return {
status: 200,
message: "Success",
language,
input: Input || "",
};
},
};