mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Add raw option to response helper
This commit is contained in:
parent
18f7cd5942
commit
e367fa55ce
|
@ -148,13 +148,13 @@ const isUniqueConstraintError = (error: Error) =>
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function send(processFunction: (req: Request, res: Response) => Promise<any>) {
|
export function send(processFunction: (req: Request, res: Response) => Promise<any>, raw = false) {
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
return async (req: Request, res: Response) => {
|
return async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const data = await processFunction(req, res);
|
const data = await processFunction(req, res);
|
||||||
|
|
||||||
sendSuccessResponse(res, data);
|
sendSuccessResponse(res, data, raw);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && isUniqueConstraintError(error)) {
|
if (error instanceof Error && isUniqueConstraintError(error)) {
|
||||||
error.message = 'There is already an entry with this name';
|
error.message = 'There is already an entry with this name';
|
||||||
|
|
Loading…
Reference in a new issue