blob: 3e8c9321485a73340ffabae2d6c4820cecc23419 (
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
39
40
41
42
|
import { MongoDatabase, Database } from "lambert-db";
import { Server, ServerOptions } from "lambert-server";
const log = console.log;
console.log = (content) => {
log(`[${new Date().toTimeString().split(" ")[0]}]`, content);
};
declare global {
namespace Express {
interface Request {
cdn: CDNServer;
}
}
}
export interface CDNServerOptions extends ServerOptions {
db: string;
}
export class CDNServer extends Server {
db: Database;
public options: CDNServerOptions;
constructor(options: Partial<CDNServerOptions>) {
super(options);
this.db = new MongoDatabase(options?.db);
}
async start() {
console.log("[Database] connecting ...");
await this.db.init();
console.log("[Database] connected");
return super.start();
}
async stop() {
await this.db.destroy();
return super.stop();
}
}
|