29 lines
742 B
TypeScript
29 lines
742 B
TypeScript
import useDatabase from '~/composables/useDatabase';
|
|
|
|
export default defineEventHandler(async (e) => {
|
|
const project = getRouterParam(e, "projectId");
|
|
const query = getQuery(e);
|
|
|
|
if(!project || !query.path)
|
|
{
|
|
setResponseStatus(e, 404);
|
|
return;
|
|
}
|
|
|
|
const where = ["project = $project", "path = $path"];
|
|
const criteria: Record<string, any> = { $project: project, $path: query.path };
|
|
|
|
if(where.length > 1)
|
|
{
|
|
const db = useDatabase();
|
|
|
|
const content = db.query(`SELECT * FROM explorer_comments WHERE ${where.join(" and ")}`).all(criteria) as Comment[];
|
|
|
|
if(content.length > 0)
|
|
{
|
|
return content;
|
|
}
|
|
}
|
|
|
|
setResponseStatus(e, 404);
|
|
}); |