mirror of
https://github.com/dadosfera/maestro.git
synced 2026-12-05 12:20:04 +00:00
93 lines
2.4 KiB
TypeScript
93 lines
2.4 KiB
TypeScript
import { Controller, Get, Post, Body, Patch, Param, Delete, Put, Headers} from '@nestjs/common';
|
|
import { RestEnrichmentsService } from './rest-enrichments.service';
|
|
import { CreateRestEnrichmentDto } from './dto/create-rest-enrichment.dto';
|
|
import { UpdateRestEnrichmentDto } from './dto/update-rest-enrichment.dto';
|
|
import axios from 'axios';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
|
|
@ApiTags('Enrichments')
|
|
@Controller('enrichment')
|
|
export class RestEnrichmentsController {
|
|
constructor(private readonly restEnrichmentsService: RestEnrichmentsService) {}
|
|
|
|
@Post()
|
|
async create(@Body() body: CreateRestEnrichmentDto,@Headers() headers) {
|
|
|
|
const connectionResponse = await axios.post(
|
|
`${process.env.DEV_URL}/enrichment`,
|
|
body,
|
|
{
|
|
headers:{
|
|
"Authorization":headers.authorization,
|
|
"Content-Type":"application/json"
|
|
}
|
|
}
|
|
)
|
|
|
|
return connectionResponse.data
|
|
}
|
|
|
|
@Get()
|
|
async list(@Headers() headers) {
|
|
|
|
const connectionResponse = await axios.get(
|
|
`${process.env.DEV_URL}/enrichment`,
|
|
{
|
|
headers:{
|
|
"Authorization":headers.authorization
|
|
}
|
|
}
|
|
)
|
|
|
|
return connectionResponse.data
|
|
}
|
|
|
|
@Get(':id')
|
|
async show(@Param('id') id: string,@Headers() headers) {
|
|
|
|
const connectionResponse = await axios.get(
|
|
`${process.env.DEV_URL}/enrichment/${id}`,
|
|
{
|
|
headers:{
|
|
"Authorization":headers.authorization
|
|
}
|
|
}
|
|
)
|
|
|
|
return connectionResponse.data
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(@Param('id') id: string,@Headers() headers, @Body() body: UpdateRestEnrichmentDto) {
|
|
|
|
const connectionResponse = await axios.put(
|
|
`${process.env.DEV_URL}/enrichment/${id}`,
|
|
body,
|
|
{
|
|
headers:{
|
|
"Authorization":headers.authorization,
|
|
"Content-Type":"application/json"
|
|
}
|
|
}
|
|
)
|
|
|
|
return connectionResponse.data
|
|
}
|
|
|
|
@Delete(':id')
|
|
async remove(@Param('id') id: string,@Headers() headers) {
|
|
|
|
const connectionResponse = await axios.delete(
|
|
`${process.env.DEV_URL}/enrichment/${id}`,
|
|
{
|
|
headers:{
|
|
"Authorization":headers.authorization,
|
|
"Content-Type":"application/json"
|
|
}
|
|
}
|
|
)
|
|
|
|
return connectionResponse.data
|
|
}
|
|
}
|