public code v1

This commit is contained in:
2026-05-22 09:58:02 +02:00
commit 9669f6520f
35 changed files with 9665 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
const express = require("express");
const bodyParser = require('body-parser');
class Express {
#app;
#name;
#port;
constructor(port, name = "Service") {
this.#app = express();
this.#app.use(bodyParser.json());
this.#app.use(bodyParser.urlencoded({ extended: true }));
this.#name = name;
this.#port = port;
}
get app() {
return this.#app;
}
get = (path, f) => this.#app.get(path, f);
post = (path, f) => this.#app.post(path, f);
put = (path, f) => this.#app.put(path, f);
delete = (path, f) => this.#app.delete(path, f);
run = () => {
this.#app.listen(this.#port, () =>
console.log(`${this.#name} listening on port ${this.#port}`)
);
}
}
module.exports.Express = Express;
+56
View File
@@ -0,0 +1,56 @@
const axios = require("axios");
function promiseGetRequest(url) {
return new Promise((resolve, reject) => {
console.log(url)
axios.get(url)
.then(res => {
resolve(res.data);
})
.catch(err => {
reject(err);
});
}
)
}
function promisePostRequest(url, body) {
return new Promise((resolve, reject) => {
axios.post(url, body)
.then(res => {
resolve(res.data);
})
.catch(err => {
reject(err);
});
}
)
}
function promisePutRequest(url, body) {
return new Promise((resolve, reject) => {
axios.put(url, body)
.then(res => {
resolve(res.data);
})
.catch(err => {
reject(err);
});
}
)
}
function promiseDeleteRequest(url, body) {
return new Promise((resolve, reject) => {
axios.delete(url, { data: body })
.then(res => {
resolve(res.data);
})
.catch(err => {
reject(err);
});
}
)
}
module.exports = {promiseGetRequest, promisePostRequest, promiseDeleteRequest}
+1019
View File
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
{
"name": "core",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.1",
"express": "^4.18.2"
}
}