u
This commit is contained in:
@@ -2,6 +2,8 @@ import sharp from 'sharp';
|
||||
import * as dbCompanySetting from '../../db/companysetting.js';
|
||||
import { crawlAndProcessImage } from '../../services/imageCrop.js';
|
||||
|
||||
// #region Helpers
|
||||
|
||||
const CONCURRENCY = 6;
|
||||
const FETCH_TIMEOUT_MS = 6000;
|
||||
|
||||
@@ -83,6 +85,8 @@ async function generateWebpThumbnail(img, { signal, preferSource = false } = {})
|
||||
throw lastError || new Error('Failed to load thumbnail');
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* Registers Serper image search routes.
|
||||
* @param {import('express').Application} app
|
||||
@@ -186,6 +190,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region POST /serper/images
|
||||
|
||||
const handleImagesSearch = async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -341,6 +347,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /serper/image:
|
||||
@@ -411,6 +419,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region POST /serper/image
|
||||
|
||||
const handleImageCrop = async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -438,6 +448,17 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region POST /serper/images (registration)
|
||||
|
||||
app.post(`${basePath}/serper/images`, handleImagesSearch);
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region POST /serper/image (registration)
|
||||
|
||||
app.post(`${basePath}/serper/image`, handleImageCrop);
|
||||
|
||||
// #endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user