Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaups #101

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"topLevel": false
}
},
"target": "es2021",
"target": "esnext",
"parser": {
"syntax": "typescript",
"tsx": false,
Expand Down
8 changes: 3 additions & 5 deletions src/controllers/rest/impl/FileUploadController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { FileUploadModelResponse } from "../../../model/rest/FileUploadModelResp
import { BadRequest, Forbidden, UnsupportedMediaType } from "@tsed/exceptions";
import { MultipartFile, PathParams, type PlatformMulterFile, QueryParams, Req, Res } from "@tsed/common";
import { BodyParams } from "@tsed/platform-params";
import { FileEngine } from "../../../engine/impl/index.js";
import { FileService } from "../../../services/FileService.js";
import { NetworkUtils } from "../../../utils/Utils.js";
import { FileUtils, NetworkUtils } from "../../../utils/Utils.js";
import { BaseRestController } from "../BaseRestController.js";
import { Logger } from "@tsed/logger";

Expand All @@ -17,7 +16,6 @@ import { Logger } from "@tsed/logger";
@Returns(StatusCodes.FORBIDDEN, Forbidden).Description("If your IP has been blocked")
export class FileUploadController extends BaseRestController {
public constructor(
@Inject() private fileEngine: FileEngine,
@Inject() private fileUploadService: FileService,
@Inject() private logger: Logger,
) {
Expand Down Expand Up @@ -75,7 +73,7 @@ export class FileUploadController extends BaseRestController {
): Promise<unknown> {
if (file && url) {
if (file) {
await this.fileEngine.deleteFile(file);
await FileUtils.deleteFile(file);
}
throw new BadRequest("Unable to upload both a file and a url");
}
Expand Down Expand Up @@ -106,7 +104,7 @@ export class FileUploadController extends BaseRestController {
if (file) {
// this will delete files if something goes wrong, but not urls...
// TODO: fix
await this.fileEngine.deleteFile(file, true);
await FileUtils.deleteFile(file, true);
}
throw e;
}
Expand Down
37 changes: 0 additions & 37 deletions src/engine/impl/FileEngine.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/engine/impl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @file Automatically generated by barrelsby.
*/

export * from "./FileEngine.js";
export * from "./av/ClamAvEngine.js";
export * from "./av/MsDefenderEngine.js";
export * from "./HttpErrorRenderers/AuthenticationErrorRenderEngine.js";
Expand Down
7 changes: 3 additions & 4 deletions src/manager/AvManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Inject, Injectable, OnInit } from "@tsed/di";
import { AvFactory } from "../factory/AvFactory.js";
import type { PlatformMulterFile } from "@tsed/common";
import { Logger } from "@tsed/logger";
import { FileEngine } from "../engine/impl/index.js";
import { BadRequest } from "@tsed/exceptions";
import path from "node:path";
import { IAvEngine } from "../engine/IAvEngine.js";
import { AvScanResult } from "../utils/typeings.js";
import { FileUtils } from "../utils/Utils.js";

@Injectable()
export class AvManager implements OnInit {
Expand All @@ -15,7 +15,6 @@ export class AvManager implements OnInit {
public constructor(
@Inject() private avFactory: AvFactory,
@Inject() private logger: Logger,
@Inject() private fileEngine: FileEngine,
) {}

public async $onInit(): Promise<void> {
Expand All @@ -42,10 +41,10 @@ export class AvManager implements OnInit {
if (scanResult.passed) {
continue;
}
const fileExists = await this.fileEngine.fileExists(resource);
const fileExists = await FileUtils.fileExists(resource);
if (fileExists) {
try {
await this.fileEngine.deleteFile(file, false);
await FileUtils.deleteFile(file, false);
} catch (e) {
// this basically means we could not delete the virus...
this.logger.error(`Unable to delete resource ${resource} after positive AV detection`);
Expand Down
2 changes: 1 addition & 1 deletion src/public/assets/custom/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@
font-size: 2rem;
}

.am5-modal-content{
.am5-modal-content {
color: #000000 !important;
}
10 changes: 5 additions & 5 deletions src/public/assets/custom/js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Site = (function () {
const Site = (function() {
let isInit = false;

const loading = function loading(show) {
Expand Down Expand Up @@ -52,14 +52,14 @@ const Site = (function () {
// eslint-disable-next-line require-await
anon.call(this, Site).then(async () => {
function initTooltips() {
document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
document.querySelectorAll("[data-bs-toggle=\"tooltip\"]").forEach(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
}

function initTabs() {
const triggerTabList = document.querySelectorAll('#resultTabs button');
const triggerTabList = document.querySelectorAll("#resultTabs button");
triggerTabList.forEach(triggerEl => {
const tabTrigger = new bootstrap.Tab(triggerEl);
triggerEl.addEventListener('click', event => {
triggerEl.addEventListener("click", event => {
event.preventDefault();
tabTrigger.show();
});
Expand All @@ -76,6 +76,6 @@ const Site = (function () {
loading,
display,
showSuccess,
showError,
showError
};
}());
141 changes: 0 additions & 141 deletions src/public/assets/custom/js/spinWheel.js

This file was deleted.

38 changes: 19 additions & 19 deletions src/public/fileLogin.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
submitPassword();
});

function progress({loaded, total}) {
const downloadDone = Math.round(loaded / total * 100) + '%';
function progress({ loaded, total }) {
const downloadDone = Math.round(loaded / total * 100) + "%";
progressbar.innerText = downloadDone;
progressbar.style.width = downloadDone;
progressWrapper.setAttribute("aria-valuenow", Math.round(loaded / total * 100).toString());
Expand All @@ -78,35 +78,35 @@
const response = await fetch(url, {
headers: {
"x-password": password
},
}
});
if (response.status === 403) {
alert.classList.remove("hidden");
return;
}
const contentLength = response.headers.get('content-length');
const contentLength = response.headers.get("content-length");
const total = Number.parseInt(contentLength);
let loaded = 0;
const res = new Response(
new ReadableStream({
async start(controller) {
const reader = response.body.getReader();
for (; ;) {
try {
const {done, value} = await reader.read();
if (done) {
break;
}
loaded += value.byteLength;
progress({loaded, total});
controller.enqueue(value);
} catch (e) {
controller.error(e);
async start(controller) {
const reader = response.body.getReader();
for (; ;) {
try {
const { done, value } = await reader.read();
if (done) {
break;
}
loaded += value.byteLength;
progress({ loaded, total });
controller.enqueue(value);
} catch (e) {
controller.error(e);
return;
}
}
controller.close();
}
controller.close();
},
}
), {
headers: response.headers,
Expand Down
4 changes: 2 additions & 2 deletions src/public/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<a href="/" class="text-body-emphasis text-decoration-none">
<span class="fs-4">WaifuVault</span>
</a>
<a class="btn btn-secondary" href="https://github.com/VictoriqueMoe/WaifuVault" target="_blank"><i class="bi bi-github"></i> Source</a>
<a class="btn btn-secondary" href="https://github.com/waifuvault/WaifuVault" target="_blank"><i class="bi bi-github"></i> Source</a>
</header>

<div class="p-5 mb-4 bg-body-tertiary rounded-3 border border-primary-subtle position-relative">
Expand All @@ -22,7 +22,7 @@
<a href="https://0x0.st" target="_blank">https://0x0.st</a>, WaifuVault is a temporary file hosting service that allows for file uploads that are hosted for a set amount of time.
</p>
<a class="btn btn-primary btn-lg" type="button" href="/api-docs" target="_blank">Api Documentation</a>
<img id="victorique" class="img-fluid" src="assets/custom/images/08.png" alt="logo"/>
<img id="victorique" class="img-fluid" src="assets/custom/images/08.png" alt="logo" />
</div>
</div>

Expand Down
Loading