summary refs log tree commit diff
path: root/src/Server.ts
blob: 57dfa5364f7e637c73fdcabeb06e84fe60851ade (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Server, ServerOptions } from "lambert-server";
import { Config, db } from "@fosscord/server-util";
import path from "path";
import multerConfig from "multer";

export interface CDNServerOptions extends ServerOptions {}

export class CDNServer extends Server {
	public options: CDNServerOptions;

	constructor(options?: Partial<CDNServerOptions>) {
		super(options);
	}

	async start() {
		console.log("[Database] connecting ...");
		// @ts-ignore
		await (db as Promise<Connection>);
		await Config.init();
		console.log("[Database] connected");

		await this.registerRoutes(path.join(__dirname, "routes/"));
		return super.start();
	}

	async stop() {
		return super.stop();
	}
}

export const multer = multerConfig({
	storage: multerConfig.memoryStorage(),
	limits: {
		fields: 10,
		files: 10,
		fileSize: 1024 * 1024 * 100, // 100 mb
	},
});