feat(01-02): add data directory, server hooks, and verification page
- Create data/ directory with attachments/ subdirectory and .gitkeep files - Update .gitignore to track .gitkeep but ignore database files - Server hooks initialize database on first request - Page server load fetches entries and creates test entry if none exist - Verification page shows database status, entry count, and recent entries
This commit is contained in:
24
src/routes/+page.server.ts
Normal file
24
src/routes/+page.server.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { entryRepository } from '$lib/server/db/repository';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
const count = entryRepository.count();
|
||||
|
||||
// Create a test entry if none exist (for verification)
|
||||
let testEntry = null;
|
||||
if (count === 0) {
|
||||
testEntry = entryRepository.create({
|
||||
title: 'Foundation Test',
|
||||
content: 'This entry was created to verify the foundation is working.',
|
||||
type: 'thought'
|
||||
});
|
||||
}
|
||||
|
||||
const entries = entryRepository.getAll({ limit: 5 });
|
||||
|
||||
return {
|
||||
dbStatus: 'connected',
|
||||
entryCount: testEntry ? count + 1 : count,
|
||||
recentEntries: entries
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user