CDN: unify imports layout

This commit is contained in:
Rory&
2026-06-12 16:49:37 +02:00
parent 03ecae4348
commit fb7199f27a
22 changed files with 50 additions and 82 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
import path from "node:path";
import morgan from "morgan";
import { Server, ServerOptions } from "lambert-server/Server";
import { CORS, BodyParser } from "@spacebar/api";
import { CORS, BodyParser } from "@spacebar/api/middlewares";
import { Attachment, initDatabase } from "@spacebar/database";
import { Config, registerRoutes } from "@spacebar/util";
import { ProcessLifecycle } from "../util/util/ProcessLifecycle";
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+1 -3
View File
@@ -22,9 +22,7 @@ import imageSize from "image-size";
import { HTTPError } from "lambert-server/HTTPError";
import { CloudAttachment } from "@spacebar/database";
import { Config, hasValidSignature, NewUrlUserSignatureData, Snowflake, UrlSignResult } from "@spacebar/util";
import { storage } from "@spacebar/cdn/util/Storage";
import { multer } from "@spacebar/cdn/util/multer";
import { cache } from "@spacebar/cdn/util/cache";
import { storage, multer, cache } from "@spacebar/cdn/util";
const router = Router({ mergeParams: true });
+1 -2
View File
@@ -17,10 +17,9 @@
*/
import { Router, Response, Request } from "express";
import { storage } from "@spacebar/cdn";
import { HTTPError } from "lambert-server/HTTPError";
import { fileTypeFromBuffer } from "file-type";
import { cache } from "../util/cache";
import { storage, cache } from "@spacebar/cdn/util";
const router = Router({ mergeParams: true });
+1 -3
View File
@@ -20,10 +20,8 @@ import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { fileTypeFromBuffer } from "file-type";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { HTTPError } from "lambert-server/HTTPError";
import { multer } from "../util/multer";
import { cache } from "../util/cache";
import { storage, multer, cache } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+1 -2
View File
@@ -17,10 +17,9 @@
*/
import { Router, Response, Request } from "express";
import { storage } from "@spacebar/cdn";
import { HTTPError } from "lambert-server/HTTPError";
import { fileTypeFromBuffer } from "file-type";
import { cache } from "../util/cache";
import { storage, cache } from "@spacebar/cdn/util";
const router = Router({ mergeParams: true });
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -3
View File
@@ -16,12 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Request, Response, Router } from "express";
import fs from "node:fs/promises";
import { HTTPError } from "lambert-server/HTTPError";
import { join } from "node:path";
import { Request, Response, Router } from "express";
import { fileTypeFromBuffer } from "file-type";
import { cache } from "../util/cache";
import { HTTPError } from "lambert-server/HTTPError";
import { cache } from "@spacebar/cdn/util";
const defaultAvatarHashMap = new Map([
["0", "4a8562cf00887030c416d3ec2d46385a"],
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Config } from "@spacebar/util";
import crypto from "node:crypto";
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server/HTTPError";
import { multer } from "../util/multer";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { cache } from "../util/cache";
import { HTTPError } from "lambert-server/HTTPError";
import { Config } from "@spacebar/util";
import { storage, multer, cache } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache } from "@spacebar/cdn/util";
//Role icons ---> avatars.ts modified
+3 -5
View File
@@ -17,13 +17,11 @@
*/
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import crypto from "node:crypto";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+3 -5
View File
@@ -16,14 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import crypto from "node:crypto";
import { Router, Response, Request } from "express";
import { Config } from "@spacebar/util";
import { storage } from "@spacebar/cdn";
import { fileTypeFromBuffer } from "file-type";
import { HTTPError } from "lambert-server/HTTPError";
import crypto from "node:crypto";
import { multer } from "../util/multer";
import { cache, cacheNotFound } from "../util/cache";
import { Config } from "@spacebar/util";
import { storage, multer, cache, cacheNotFound } from "@spacebar/cdn/util";
// TODO: check premium and animated pfp are allowed in the config
// TODO: generate different sizes of icon
+1 -1
View File
@@ -16,11 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Storage } from "./Storage";
import fs from "node:fs";
import fsp from "node:fs/promises";
import { join, dirname } from "node:path";
import { Readable } from "node:stream";
import { Storage } from "./Storage";
import ExifTransformer from "exif-be-gone";
export class FileStorage implements Storage {
+1 -1
View File
@@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { FileStorage } from "./FileStorage";
import path from "node:path";
import fs from "node:fs";
import { red } from "picocolors";
@@ -46,6 +45,7 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) {
if (!fs.existsSync(location)) fs.mkdirSync(location);
process.env.STORAGE_LOCATION = location;
const { FileStorage } = require("./FileStorage");
storage = new FileStorage();
} else if (process.env.STORAGE_PROVIDER === "s3") {
try {
+1 -1
View File
@@ -16,6 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export * from "./FileStorage";
export * from "./cache";
export * from "./multer";
export * from "./Storage";