3035 improve rest api syntax (#3047)

This commit is contained in:
martmull
2023-12-18 13:46:21 +01:00
committed by GitHub
parent b36d86e52c
commit 576492f3c0
6 changed files with 102 additions and 39 deletions

View File

@ -3,17 +3,7 @@ import { Controller, Delete, Get, Post, Put, Req, Res } from '@nestjs/common';
import { Request, Response } from 'express';
import { ApiRestService } from 'src/core/api-rest/api-rest.service';
import { ApiRestResponse } from 'src/core/api-rest/types/api-rest-response.type';
const handleResult = (res: Response, result: ApiRestResponse) => {
if (result.data.error) {
res
.status(result.data.status || 400)
.send({ error: `${result.data.error}` });
} else {
res.send(result.data);
}
};
import { handleResult } from 'src/core/api-rest/api-rest.controller.utils';
@Controller('rest/*')
export class ApiRestController {