upload files into repos

This commit is contained in:
FullGreaM 2022-10-05 09:27:14 +03:00
parent 8fa615212c
commit 4f9a1b8fa2
2 changed files with 39 additions and 4 deletions

View File

@ -1,4 +1,4 @@
const backend = require('index');
const backend = require('./index');
// Создаём экземпляр класса backend.Main
var server = new backend.Main(
@ -37,7 +37,7 @@ server.paramsError = (required, additional) => ({ required, additional });
// Создаём класс группы методов
class ExampleMethodGroup extends backend.Group {
handler (params, session) { // Путевая обработка
handler (params, session) { // Путевая обработка
session._setValue('example', 1); // Задать значение
console.log(session.example); // Получить значение из сессии
session._remove('example'); // Убрать значение
@ -67,7 +67,6 @@ var exampleMethod = new ExampleMethod('/example', {
max_length : 255,
// allow_methods : ['post'],
// allow_params : ['json'],
}
});
// Привяжем метод к группе
@ -76,4 +75,4 @@ exampleMethod.group(ExampleMethodGroup);
server.method(exampleMethod);
// Запускаем сервер
server.server().listen(8080);
server.server('/api/v1'/*, { Информация о SSL }*/).listen(8080);

View File

@ -1,6 +1,42 @@
const express = require('express');
const https = require('https');
const version = 'v 1.0.0';
class Main {
constructor (send_headers = true) {
this.send_headers = send_headers;
this.methods = new Object();
}
method (methodObj) {
this.methods[methodObj.path] = methodObj;
}
router (returnMiddlewareFunction = true, middlewareFunction = (req, res, next) => next()) {
let router = express.Router();
for (let path in this.methods) {
for (let methodId in this.methods[path].allowedMethods) {
router[this.methods[path].allowedMethods[methodId]](async (req, res) => {
// (!) Mainbody
});
}
}
if (returnMiddlewareFunction) {
return middlewareFunction, router;
}
else {
return router;
}
}
server (mountPath = '/', options = null) {
let app = express();
app.use(mountPath, this.router());
return app;
}
}