This commit is contained in:
Bright 2024-02-28 10:37:48 +07:00
parent 5f222498cb
commit a5daa9d742
4 changed files with 114 additions and 1 deletions

View file

@ -1,4 +1,6 @@
import { Controller, Get, Post, Put, Delete, Patch, Route, Security, Tags } from "tsoa";
import { Controller, Request, Get, Post, Put, Delete, Patch, Route, Security, Tags, Path } from "tsoa";
import axios from 'axios';
import CallAPI from "../interfaces/call-api";
@Route("/hello")
@Tags("Test")
@ -8,4 +10,18 @@ export class AppController extends Controller {
public async GET() {
return { message: "Hello Salary" };
}
/**
* API Call Org
*
* @summary API Call Org
*
*/
@Get("CallOrg")
public async CallOrg(
@Request() request: any,
) {
const req = await new CallAPI().GetData(request, 'org/profile/salary/gen');
return req;
}
}

View file

@ -0,0 +1,24 @@
import { Controller, Request, Get, Post, Put, Delete, Patch, Route, Security, Tags, Path } from "tsoa";
import axios from 'axios';
class CallAPI {
//Get
public async GetData(request: any, @Path() path: any) {
const token = request.headers.authorization;
const url = process.env.ORG_API+path;
try {
const response = await axios.get(url, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
return response.data;
} catch (error) {
throw error;
}
}
}
export default CallAPI;