Kaydet (Commit) ceed0e0c authored tarafından Hakkı Dizdar's avatar Hakkı Dizdar

Park oluşturma isteğine doğrulamalar eklendi

üst e1ce20ff
......@@ -5,6 +5,7 @@ const Docker = require("dockerode");
const docker = new Docker();
const ws = require("express-ws")(app);
const cors = require("cors");
const { checkSchema } = require("express-validator");
const { convert } = require("./docker/names");
app.use(cors());
app.use(compression());
......@@ -43,9 +44,29 @@ app.get("/images", (_, res) => {
});
});
app.post("/create", (req, res) => {
require("./docker/controllers/create")(req, res);
});
app.post(
"/create",
checkSchema({
image: {
in: ["nyxteam/oyunparki-full", "nyxteam/oyunparki-small"],
errorMessage: "Yanlış versiyon seçildi!",
},
username: {
nullable: true,
},
password: {
nullable: true,
},
max_ram: { isInt: true, toInt: true },
spice_password: {
isBoolean: true,
toBoolean: true,
},
}),
(req, res) => {
require("./docker/controllers/create")(req, res);
}
);
app.post("/restart", (req, res) => {
res.send(docker.getContainer(req.body.container).restart());
......
......@@ -730,6 +730,15 @@
"vary": "~1.1.2"
}
},
"express-validator": {
"version": "6.10.1",
"resolved": "https://registry.npmjs.org/express-validator/-/express-validator-6.10.1.tgz",
"integrity": "sha512-joYSJdkUyKMZ2gAUvyQNmqJ7x1vhrC/IHCKWauhKfoXNF83j65KnlqEEXXynBnJRd0QrNZ/aXw9uIhS6ptG0Cg==",
"requires": {
"lodash": "^4.17.21",
"validator": "^13.5.2"
}
},
"express-ws": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/express-ws/-/express-ws-4.0.0.tgz",
......@@ -1003,8 +1012,7 @@
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"lodash.clonedeep": {
"version": "4.5.0",
......@@ -1606,6 +1614,11 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true
},
"validator": {
"version": "13.6.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-13.6.0.tgz",
"integrity": "sha512-gVgKbdbHgtxpRyR8K0O6oFZPhhB5tT1jeEHZR0Znr9Svg03U0+r9DXWMrnRAB+HtCStDQKlaIZm42tVsVjqtjg=="
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
......
......@@ -21,6 +21,7 @@
"cors": "^2.8.5",
"dockerode": "^3.3.0",
"express": "^4.17.1",
"express-validator": "^6.10.1",
"express-ws": "^4.0.0",
"stream": "0.0.2"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment