@@ -40,6 +40,36 @@ const apiMetadataSchema = serializr.createSimpleSchema({
4040 )
4141} ) ;
4242
43+ // In addition to the public OpenAPI directory, we have a few extra APIs (stored in
44+ // this repo in /extra-apis) that we match seprately:
45+ const EXTRA_APIS : { [ urlPrefix : string ] : 'ipfs' | 'ethereum' } = {
46+ // See the 'servers' field in /extra-apis/ipfs.json:
47+ 'localhost:5001/api/v0' : 'ipfs' ,
48+ '127.0.0.1:5001/api/v0' : 'ipfs' ,
49+ 'ipfs.infura.io:5001/api/v0' : 'ipfs' ,
50+
51+ // See the 'servers' field in /extra-apis/ethereum.json:
52+ 'localhost:8545/' : 'ethereum' ,
53+ '127.0.0.1:8545/' : 'ethereum' ,
54+ 'mainnet.infura.io/v3/' : 'ethereum' ,
55+ 'ropsten.infura.io/v3/' : 'ethereum' ,
56+ 'rinkeby.infura.io/v3/' : 'ethereum' ,
57+ 'kovan.infura.io/v3/' : 'ethereum' ,
58+ 'goerli.infura.io/v3/' : 'ethereum'
59+ } ;
60+
61+ function findPublicApi ( url : string ) {
62+ const openApiId = findPublicOpenApi ( url ) ;
63+
64+ if ( openApiId ) return openApiId ;
65+
66+ const matchingExtraApiKey = Object . keys ( EXTRA_APIS )
67+ . find ( ( apiPrefix ) => url . startsWith ( apiPrefix ) ) ;
68+
69+ if ( matchingExtraApiKey ) return EXTRA_APIS [ matchingExtraApiKey ] ;
70+ else return undefined ;
71+ }
72+
4373export class ApiStore {
4474
4575 constructor (
@@ -156,7 +186,7 @@ export class ApiStore {
156186 // If not, is this a known public API? (note that private always has precedence)
157187 const requestUrl = `${ parsedUrl . host } ${ parsedUrl . pathname } ` ;
158188
159- let publicSpecId = findPublicOpenApi ( requestUrl ) ;
189+ let publicSpecId = findPublicApi ( requestUrl ) ;
160190 if ( ! publicSpecId ) return ;
161191 if ( ! Array . isArray ( publicSpecId ) ) publicSpecId = [ publicSpecId ] ;
162192
0 commit comments