Added boob and country aggregation to actors page.
This commit is contained in:
@@ -1,19 +1,34 @@
|
||||
import { fetchActors } from '../actors.js';
|
||||
|
||||
export function curateActorsQuery(query) {
|
||||
console.log('input query', query);
|
||||
|
||||
return {
|
||||
query: query.q,
|
||||
gender: query.gender,
|
||||
age: query.age?.split(',').map((age) => Number(age)),
|
||||
cup: query.cup?.split(','),
|
||||
naturalBoobs: query.nb,
|
||||
height: query.height?.split(',').map((height) => Number(height)),
|
||||
weight: query.weight?.split(',').map((weight) => Number(weight)),
|
||||
requireAvatar: query.avatar,
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchActorsApi(req, res) {
|
||||
const { actors, limit, total } = await fetchActors({
|
||||
query: req.query.q,
|
||||
requireAvatar: Object.hasOwn(req.query, 'avatar'),
|
||||
age: req.query.age?.split(',').map((age) => Number(age)),
|
||||
height: req.query.height?.split(',').map((height) => Number(height)),
|
||||
weight: req.query.weight?.split(',').map((weight) => Number(weight)),
|
||||
}, {
|
||||
const {
|
||||
actors,
|
||||
countries,
|
||||
limit,
|
||||
total,
|
||||
} = await fetchActors(curateActorsQuery(req.query), {
|
||||
page: Number(req.query.page) || 1,
|
||||
limit: Number(req.query.limit) || 50,
|
||||
});
|
||||
|
||||
res.send({
|
||||
actors,
|
||||
countries,
|
||||
limit,
|
||||
total,
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
import config from 'config';
|
||||
import express from 'express';
|
||||
import boolParser from 'express-query-boolean';
|
||||
import Router from 'express-promise-router';
|
||||
import compression from 'compression';
|
||||
import { renderPage } from 'vike/server'; // eslint-disable-line import/extensions
|
||||
@@ -30,6 +31,8 @@ async function startServer() {
|
||||
app.use(compression());
|
||||
app.disable('x-powered-by');
|
||||
|
||||
router.use(boolParser());
|
||||
|
||||
router.use('/', express.static('public'));
|
||||
router.use('/', express.static('static'));
|
||||
router.use('/media', express.static(config.media.path));
|
||||
@@ -66,6 +69,7 @@ async function startServer() {
|
||||
router.get('*', async (req, res, next) => {
|
||||
const pageContextInit = {
|
||||
urlOriginal: req.originalUrl,
|
||||
urlQuery: req.query, // vike's own query does not apply boolean parser
|
||||
};
|
||||
|
||||
const pageContext = await renderPage(pageContextInit);
|
||||
|
||||
Reference in New Issue
Block a user