Dependencies upgrade (#510)

This commit is contained in:
Montassar Ghanmy
2024-05-07 17:01:56 +01:00
committed by GitHub
parent 0487ceb7b3
commit 3b20806622
15 changed files with 5080 additions and 5846 deletions
@@ -9,7 +9,6 @@ export type TdriveLogger = pino.Logger;
export const logger = pino({
name: "TdriveApp",
level: config.get("level", "info") || "info",
prettyPrint: false,
mixin() {
return executionStorage.getStore() ? executionStorage.getStore() : {};
},
@@ -1,5 +1,5 @@
import { FastifyPluginCallback, FastifyRequest } from "fastify";
import fastifyJwt from "fastify-jwt";
import fastifyJwt from "@fastify/jwt";
import cookie from "@fastify/cookie";
import fp from "fastify-plugin";
import config from "../../../../config";
@@ -1,6 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types */
import { EntityDefinition } from "../types";
type EntityOption = {
type?: string;
ttl?: number;
@@ -18,11 +16,10 @@ type EntityOption = {
export function Entity(name: string, options: EntityOption): ClassDecorator {
// eslint-disable-next-line @typescript-eslint/ban-types
return function (constructor: Function): void {
const entityDefinition: EntityDefinition = {
constructor.prototype._entity = {
name,
type: options.type || name,
options,
};
constructor.prototype._entity = entityDefinition;
};
}
@@ -115,6 +115,10 @@ export default class StorageService extends TdriveService<StorageAPI> implements
const chunks = options?.totalChunks || 1;
let count = 1;
//check that the file a really exists
await self._read(options?.totalChunks ? `${path}/chunk${count}` : path);
let stream: any;
async function factory(callback: (err?: Error, stream?: Stream) => unknown) {
if (count > chunks) {
@@ -136,6 +140,7 @@ export default class StorageService extends TdriveService<StorageAPI> implements
if (decipher) {
stream = stream.pipe(decipher);
}
callback(null, stream);
} catch (err) {
logger.error(err);
callback(err, null);
@@ -163,6 +168,7 @@ export default class StorageService extends TdriveService<StorageAPI> implements
stream = stream.pipe(decipher);
} catch (err) {
logger.error("Unable to createDecipheriv: %s", err);
throw err;
}
}
return stream;
@@ -1,19 +1,20 @@
import { logger, TdriveService } from "../../framework";
import { Server, IncomingMessage, ServerResponse } from "http";
import { FastifyInstance, fastify } from "fastify";
import sensible from "fastify-sensible";
import { FastifyInstance, fastify, FastifyRegisterOptions, FastifyServerOptions } from "fastify";
import sensible from "@fastify/sensible";
import multipart from "fastify-multipart";
import formbody from "@fastify/formbody";
import fastifyStatic from "@fastify/static";
import corsPlugin, { FastifyCorsOptions } from "fastify-cors";
import corsPlugin, { FastifyCorsOptions } from "@fastify/cors";
import { serverErrorHandler } from "./error";
import WebServerAPI from "./provider";
import jwtPlugin from "../auth/web/jwt";
import path from "path";
import swaggerPlugin from "fastify-swagger";
import swaggerPlugin, { FastifySwaggerOptions } from "@fastify/swagger";
import { SkipCLI } from "../../framework/decorators/skip";
import fs from "fs";
import { ExecutionContext, executionStorage } from "../../framework/execution-storage";
import { FastifyListenOptions } from "fastify/types/instance";
export default class WebServerService extends TdriveService<WebServerAPI> implements WebServerAPI {
name = "webserver";
@@ -102,9 +103,11 @@ export default class WebServerService extends TdriveService<WebServerAPI> implem
staticCSP: false,
transformStaticCSP: header => header,
exposeRoute: true,
});
} as FastifyRegisterOptions<FastifySwaggerOptions>);
this.server.register(jwtPlugin);
this.server.register(sensible, { errorHandler: false });
this.server.register(sensible, {
errorHandler: false,
} as FastifyRegisterOptions<FastifyServerOptions>);
this.server.register(multipart);
this.server.register(formbody);
this.server.register(corsPlugin, this.configuration.get<FastifyCorsOptions>("cors", {}));
@@ -138,7 +141,10 @@ export default class WebServerService extends TdriveService<WebServerAPI> implem
res.type("text/html").send(stream);
});
await this.server.listen(this.configuration.get<number>("port", 3000), "0.0.0.0");
await this.server.listen({
port: this.configuration.get<number>("port", 3000),
host: "0.0.0.0",
} as FastifyListenOptions);
this.server.ready(err => {
if (err) throw err;