refactor: split backend by context instead of type 'controllers/models/...'

This commit is contained in:
Sonny
2024-11-10 22:26:00 +01:00
parent 466c8dec3a
commit 01efb11f70
78 changed files with 230 additions and 228 deletions

View File

@@ -0,0 +1,18 @@
import type { HttpContext } from '@adonisjs/core/http';
import db from '@adonisjs/lucid/services/db';
export default class SearchController {
async search({ request, auth }: HttpContext) {
const term = request.qs()?.term;
if (!term) {
console.warn('qs term null');
return { error: 'missing "term" query param' };
}
const { rows } = await db.rawQuery('SELECT * FROM search_text(?, ?)', [
term,
auth.user!.id,
]);
return { results: rows };
}
}