Spaces:
Runtime error
Runtime error
Download apps/server/src/modules/landing/landing.controller.js from moustafa7/flwo: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/moustafa7/flwo/resolve/main/apps/server/src/modules/landing/landing.controller.js
- Command line
-
hf download hf://spaces/moustafa7/flwo/apps/server/src/modules/landing/landing.controller.js
-
curl -L -o landing.controller.js https://huggingface.co/spaces/moustafa7/flwo/resolve/main/apps/server/src/modules/landing/landing.controller.js
1.39 kB
| import { success } from '../../lib/response.js' | |
| import { prisma } from '../../config/database.js' | |
| import * as landingService from './landing.service.js' | |
| export async function getHome(req, res, next) { | |
| try { | |
| const [featuredTemplates, templatesCount, clientsCount, projectsCount] = await Promise.all([ | |
| prisma.template.findMany({ | |
| where: { isPublished: true }, | |
| select: { id: true, title: true, description: true, category: true, price: true, previewUrl: true }, | |
| orderBy: { sortOrder: 'asc' }, | |
| take: 8 | |
| }), | |
| prisma.template.count({ where: { isPublished: true } }), | |
| prisma.user.count({ where: { role: 'CLIENT' } }), | |
| prisma.order.count(), | |
| ]) | |
| success(res, { | |
| featuredTemplates, | |
| stats: { templates: templatesCount, clients: clientsCount, projects: projectsCount } | |
| }) | |
| } catch (err) { next(err) } | |
| } | |
| export async function getContent(req, res, next) { | |
| try { | |
| const data = await landingService.getAllSections() | |
| success(res, data) | |
| } catch (err) { next(err) } | |
| } | |
| export async function getCategories(req, res, next) { | |
| try { | |
| const categories = await prisma.template.groupBy({ | |
| by: ['category'], | |
| _count: true, | |
| where: { isPublished: true } | |
| }) | |
| success(res, { | |
| categories: categories.map(c => ({ name: c.category, count: c._count })) | |
| }) | |
| } catch (err) { next(err) } | |
| } | |