mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
init
This commit is contained in:
50
packages/server/src/runtime/runtime.ts
Normal file
50
packages/server/src/runtime/runtime.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Database } from '../database/database.js';
|
||||
import { Repos } from '../repos/repos.js';
|
||||
import { Runner } from '../runner/runner.js';
|
||||
import { Config } from '../config/config.js';
|
||||
import { Auth } from '../auth/auth.js';
|
||||
import { resolve } from 'path';
|
||||
|
||||
class Runtime {
|
||||
#repos: Repos;
|
||||
#runner: Runner;
|
||||
#auth: Auth;
|
||||
|
||||
constructor(options: Config) {
|
||||
const database = new Database(options.database);
|
||||
this.#repos = new Repos({ database, config: options });
|
||||
this.#runner = new Runner({ repos: this.#repos, config: options });
|
||||
this.#auth = new Auth({ config: options });
|
||||
}
|
||||
|
||||
public get repos() {
|
||||
return this.#repos;
|
||||
}
|
||||
|
||||
public get runner() {
|
||||
return this.#runner;
|
||||
}
|
||||
|
||||
public get auth() {
|
||||
return this.#auth;
|
||||
}
|
||||
|
||||
public static create = async () => {
|
||||
const runtime = new Runtime({
|
||||
database: {
|
||||
client: 'sqlite3',
|
||||
connection: {
|
||||
filename: resolve(process.cwd(), 'data', 'database.sqlite'),
|
||||
},
|
||||
useNullAsDefault: true,
|
||||
},
|
||||
files: {
|
||||
location: resolve(process.cwd(), 'data', 'files'),
|
||||
},
|
||||
});
|
||||
|
||||
return runtime;
|
||||
};
|
||||
}
|
||||
|
||||
export { Runtime };
|
||||
Reference in New Issue
Block a user