mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-23 13:36:31 +02:00
make version optional
This commit is contained in:
parent
37e83c9813
commit
21a0c60f5d
3 changed files with 8 additions and 6 deletions
|
@ -69,9 +69,9 @@ function get_job(body) {
|
||||||
message: 'language is required as a string',
|
message: 'language is required as a string',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!version || typeof version !== 'string') {
|
if (version && typeof version !== 'string') {
|
||||||
return reject({
|
return reject({
|
||||||
message: 'version is required as a string',
|
message: 'version should be a string',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!files || !Array.isArray(files)) {
|
if (!files || !Array.isArray(files)) {
|
||||||
|
@ -93,7 +93,9 @@ function get_job(body) {
|
||||||
);
|
);
|
||||||
if (rt === undefined) {
|
if (rt === undefined) {
|
||||||
return reject({
|
return reject({
|
||||||
message: `${language}-${version} runtime is unknown`,
|
message: `${language}${
|
||||||
|
version ? `-${version}` : ''
|
||||||
|
} runtime is unknown`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ module.exports.get_runtimes_matching_language_version = function (lang, ver) {
|
||||||
return runtimes.filter(
|
return runtimes.filter(
|
||||||
rt =>
|
rt =>
|
||||||
(rt.language == lang || rt.aliases.includes(lang)) &&
|
(rt.language == lang || rt.aliases.includes(lang)) &&
|
||||||
semver.satisfies(rt.version, ver)
|
(typeof ver !== 'string' || semver.satisfies(rt.version, ver))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
module.exports.get_latest_runtime_matching_language_version = function (
|
module.exports.get_latest_runtime_matching_language_version = function (
|
||||||
|
@ -211,7 +211,7 @@ module.exports.get_runtime_by_name_and_version = function (runtime, ver) {
|
||||||
rt =>
|
rt =>
|
||||||
(rt.runtime == runtime ||
|
(rt.runtime == runtime ||
|
||||||
(rt.runtime === undefined && rt.language == runtime)) &&
|
(rt.runtime === undefined && rt.language == runtime)) &&
|
||||||
semver.satisfies(rt.version, ver)
|
(typeof ver !== 'string' || semver.satisfies(rt.version, ver))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -238,8 +238,8 @@ Content-Type: application/json
|
||||||
This endpoint requests execution of some arbitrary code.
|
This endpoint requests execution of some arbitrary code.
|
||||||
|
|
||||||
- `language` (**required**) The language to use for execution, must be a string and must be installed.
|
- `language` (**required**) The language to use for execution, must be a string and must be installed.
|
||||||
- `version` (**required**) The version of the language to use for execution, must be a string containing a SemVer selector for the version or the specific version number to use.
|
|
||||||
- `files` (**required**) An array of files containing code or other data that should be used for execution. The first file in this array is considered the main file.
|
- `files` (**required**) An array of files containing code or other data that should be used for execution. The first file in this array is considered the main file.
|
||||||
|
- `version` (_optional_) The version of the language to use for execution, must be a string containing a SemVer selector for the version or the specific version number to use. Latest version will be used if not specified.
|
||||||
- `files[].name` (_optional_) The name of the file to upload, must be a string containing no path or left out.
|
- `files[].name` (_optional_) The name of the file to upload, must be a string containing no path or left out.
|
||||||
- `files[].content` (**required**) The content of the files to upload, must be a string containing text to write.
|
- `files[].content` (**required**) The content of the files to upload, must be a string containing text to write.
|
||||||
- `files[].encoding` (_optional_) The encoding scheme used for the file content. One of `base64`, `hex` or `utf8`. Defaults to `utf8`.
|
- `files[].encoding` (_optional_) The encoding scheme used for the file content. One of `base64`, `hex` or `utf8`. Defaults to `utf8`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue