UNPKG

@coko/server

Version:

Reusable server for use by Coko's projects

26 lines 1.16 kB
import { AxiosResponse } from 'axios'; import { getAccessToken } from './tokens'; /** * Calls given microservice, while taking care of authentication for you. * Services need to be defined in the config. * * First, on the service container, you need to generate a client id & secret, * then add these variables as credentials in the environment file of your app. * * This function will: * - Grab those variables from the environment / config * - Communicate with the service to get authenticated and get an access token * - Store the access token on the ServiceCredential table * - Make a call to the service with the parameters you gave it * * If the access token exists already, it will be used without calling the * service for a new one. * * If the access token exists, but has expired, this is also handled * automatically by getting a new token from the service. * * Other errors will be thrown and should be handled by your app logic. */ declare const callMicroservice: (serviceName: string, callParameters: any) => Promise<AxiosResponse>; export { callMicroservice, getAccessToken }; //# sourceMappingURL=microservices.d.ts.map