18 lines
694 B
TypeScript
18 lines
694 B
TypeScript
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
import type { ActivityJournalService } from '../../services/activityJournalService.js';
|
|
import { sendJson } from '../response.js';
|
|
|
|
export function createActivityJournalRoute({ journal }: { journal: ActivityJournalService }) {
|
|
return {
|
|
async handle(req: IncomingMessage, res: ServerResponse) {
|
|
const url = new URL(req.url || '/', 'http://localhost');
|
|
if (url.pathname !== '/api/activity-journal' || req.method !== 'GET') return false;
|
|
sendJson(res, 200, journal.page(
|
|
Number(url.searchParams.get('limit')) || 50,
|
|
url.searchParams.get('cursor'),
|
|
));
|
|
return true;
|
|
},
|
|
};
|
|
}
|