52 lines
907 B
TypeScript
52 lines
907 B
TypeScript
// services.ts
|
|
|
|
import { AuthService } from "../auth";
|
|
import { db, migrate, migrationStatus, PostgresAuthStore } from "../database";
|
|
import { getLogs, log } from "../logging";
|
|
import { anonymousUser, type User } from "../user";
|
|
|
|
const database = {
|
|
db,
|
|
migrate,
|
|
migrationStatus,
|
|
};
|
|
|
|
const logging = {
|
|
log,
|
|
getLogs,
|
|
};
|
|
|
|
const random = {
|
|
randomNumber: () => {
|
|
return Math.random();
|
|
},
|
|
};
|
|
|
|
const misc = {
|
|
sleep: (ms: number) => {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
},
|
|
};
|
|
|
|
const session = {
|
|
getUser: (): User => {
|
|
return anonymousUser;
|
|
},
|
|
};
|
|
|
|
// Initialize auth with PostgreSQL store
|
|
const authStore = new PostgresAuthStore();
|
|
const auth = new AuthService(authStore);
|
|
|
|
// Keep this asciibetically sorted
|
|
const services = {
|
|
auth,
|
|
database,
|
|
logging,
|
|
misc,
|
|
random,
|
|
session,
|
|
};
|
|
|
|
export { services };
|