@enface/js
Version:
Biometric researches
24 lines (22 loc) • 695 B
JavaScript
import { apiVersions } from './constants';
import { EnfaceApi } from './api.js';
import { apolloClient } from './apollo';
import * as utils from './utils';
export const createEnfaceApi = ({
version = apiVersions[apiVersions.length - 1],
apiKey,
client,
} = {}) => {
version = +version;
if (!apiVersions.includes(version)) {
throw new Error(
`You have specified a non-existent version of Enface API: ${version}.
Available versions: ${apiVersions.join(', ')}`
);
}
client = client || apolloClient(version, apiKey);
if (!utils.isUuid(client.apiKey)) {
throw new Error('Bad API key format');
}
return new EnfaceApi({ client });
};