- Add database.ts with connection pool, Kysely query builder, and migration runner - Create migrations for users and sessions tables (0001, 0002) - Implement PostgresAuthStore to replace InMemoryAuthStore - Wire up database service in services/index.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
53 lines
958 B
TypeScript
53 lines
958 B
TypeScript
// services.ts
|
|
|
|
import { AuthService } from "../auth";
|
|
import { config } from "../config";
|
|
import { db, migrate, migrationStatus, PostgresAuthStore } from "../database";
|
|
import { getLogs, log } from "../logging";
|
|
import { AnonymousUser, 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 };
|