-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rest-api): API gateway for rfq-indexer API and rfq API + swagger…
… merge [SLT-339] (#3323) Co-authored-by: defi-moses <[email protected]>
- Loading branch information
1 parent
e590bd9
commit 6bdb316
Showing
26 changed files
with
4,349 additions
and
1,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,11 @@ | ||
import swaggerJsdoc from 'swagger-jsdoc' | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const packageJson = require('../package.json') | ||
// Define the path to your static swagger.json file | ||
const swaggerFilePath = path.join(__dirname, '../swagger.json') | ||
|
||
const isDevelopment = process.env.NODE_ENV === 'development' | ||
const serverUrl = isDevelopment | ||
? 'http://localhost:3000' | ||
: 'https://api.synapseprotocol.com' | ||
// Read the static swagger.json file | ||
const specs = JSON.parse(fs.readFileSync(swaggerFilePath, 'utf8')) | ||
|
||
const options: swaggerJsdoc.Options = { | ||
definition: { | ||
openapi: '3.0.0', | ||
info: { | ||
title: 'Synapse Protocol REST API', | ||
version: packageJson.version, | ||
description: 'API documentation for the Synapse Protocol REST API', | ||
}, | ||
servers: [ | ||
{ | ||
url: serverUrl, | ||
}, | ||
], | ||
}, | ||
apis: ['./src/routes/*.ts', './src/*.ts'], | ||
} | ||
|
||
export const specs = swaggerJsdoc(options) | ||
// Export the specs for use in your application | ||
export { specs } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createProxyMiddleware } from 'http-proxy-middleware' | ||
|
||
export const isRFQIndexerRequest = (route: string): boolean => { | ||
return ( | ||
route.includes('/conflicting-proofs') || | ||
route.includes('/disputes') || | ||
route.includes('/invalid-relaus') || | ||
route.includes('/pending-transactions') || | ||
route.includes('/refunded-and-relayed') || | ||
route.includes('/transaction-id') | ||
) | ||
} | ||
|
||
export const isRFQAPIRequest = (route: string): boolean => { | ||
return ( | ||
route.includes('/ack') || | ||
route.includes('/bulk_quotes') || | ||
route.includes('/contracts') || | ||
route.includes('/open_quote_requests') || | ||
route.includes('/quotes') || | ||
route.includes('/rfq') || | ||
route.includes('/rfq_stream') | ||
) | ||
} | ||
|
||
export const rfqApiProxy = createProxyMiddleware({ | ||
target: 'https://rfq-api.omnirpc.io', | ||
changeOrigin: true, | ||
}) | ||
|
||
export const rfqIndexerProxy = createProxyMiddleware({ | ||
target: 'https://rfq-indexer.synapseprotocol.com/api', | ||
changeOrigin: true, | ||
}) |
Oops, something went wrong.