import Category from '#models/category';
export default class CategoriesController {
    async index({ request, response }) {
        const populate = request.qs().populate;
        const query = Category.query();
        if (populate === 'projects') {
            query.preload('projects');
        }
        const categories = await query;
        return response.ok({
            data: categories.map((c) => ({
                name: c.name,
                projects: populate === 'projects' ? c.projects : [],
            })),
        });
    }
}
//# sourceMappingURL=categories_controller.js.map