Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* globals pangolinBase */
import ky from 'ky'
const connector = ky.create({
prefixUrl: pangolinBase
})
export default {
/**
* Get project information
*/
getProject () {
return connector.get('pangolin/project.json').json()
},
/**
* Get template list
*/
getTemplates () {
return connector.get('pangolin/templates.json').json()
},
import ky, {Options} from 'ky'
import _ from 'lodash'
import {Fight, ReportEventsQuery, ReportEventsResponse} from './fflogs'
const options: Options = {
prefixUrl: process.env.REACT_APP_LOGS_BASE_URL,
}
if (process.env.REACT_APP_LOGS_API_KEY) {
options.searchParams = {
api_key: process.env.REACT_APP_LOGS_API_KEY,
}
}
// Core API via ky
export const fflogsApi = ky.create(options)
async function requestEvents(code: string, searchParams: Record) {
let response = await fflogsApi.get(
`report/events/${code}`,
{searchParams},
).json()
// If it's blank, try again, bypassing the cache
if (response === '') {
response = await fflogsApi.get(
`report/events/${code}`,
{searchParams: {...searchParams, bypassCache: 'true'}},
).json()
}
// If it's _still_ blank, bail and get them to retry
async function customDefaults() {
console.log('default ky');
let body = await ky.get('simple-get', { prefixUrl: 'http://localhost:8080' }).text();
console.log(body);
console.log('custom ky with defaults');
const customKy = ky.create({ prefixUrl: 'http://localhost:8080' });
body = await customKy('simple-get').text();
console.log(body);
const customApiKy = customKy.extend({ headers: { 'x-api-key': '1111' } });
body = await customApiKy('simple-get').text();
console.log(body);
}
constructor(readonly restEndpoint: string, readonly wsEndpoint: string, readonly seaToken: string) {
this.http = ky.create({
prefixUrl: restEndpoint,
headers: [['Authorization', `Bearer ${seaToken}`]],
})
this.publicTimelineSocket = new RxWebSocket(() => {
const ws = new WebSocket(wsEndpoint)
ws.addEventListener('open', () => {
ws.send(
JSON.stringify({
type: 'connect',
stream: 'v1/timelines/public',
token: seaToken,
}),
)
})
return ws
import {
deleteAtlasFile,
enableMappingPreview,
exportAtlasFile,
importAtlasFile,
resetAtlasmap,
documentExists,
} from './components/toolbar/toolbar-util';
import {
FieldAction,
FieldActionDefinition,
Multiplicity,
} from './models/field-action.model';
import { MappedField } from './models/mapping.model';
const api = ky.create({ headers: { 'ATLASMAP-XSRF-TOKEN': 'awesome' } });
interface IAtlasmapContext extends State {
dispatch: (value: Action) => void;
initializationService: InitializationService;
}
const AtlasmapContext = createContext(null);
export interface IAtlasmapProviderProps {
baseJavaInspectionServiceUrl: string;
baseXMLInspectionServiceUrl: string;
baseJSONInspectionServiceUrl: string;
baseMappingServiceUrl: string;
}
interface State {
import ky from "ky";
export const apiClient = ky.create({
prefixUrl: "https://conduit.productionready.io/api/",
timeout: 5000,
headers: {
"Content-Type": "application/json"
}
});