-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from alexmf91/release/1.5.1
feat: Add archiver v2 implementation and update related transactions fetching
- Loading branch information
Showing
46 changed files
with
664 additions
and
526 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
VITE_ENABLE_PROXY= | ||
VITE_QLI_API_URL= | ||
VITE_ARCHIVER_API_URL= |
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,69 +1,51 @@ | ||
import type { HttpProxy, ProxyOptions } from 'vite' | ||
|
||
export const qliApiProxy: ProxyOptions = { | ||
target: 'https://api.qubic.li', | ||
changeOrigin: true, | ||
rewrite: (path: string) => path.replace(/^\/dev-proxy-qli-api/, ''), | ||
configure: (proxy: HttpProxy.Server, options: ProxyOptions) => { | ||
proxy.on('proxyReq', (proxyReq, req, res) => { | ||
res.setHeader('Access-Control-Allow-Origin', '*') | ||
res.setHeader('Access-Control-Allow-Methods', 'GET, PUT, PATCH, POST, DELETE') | ||
res.setHeader( | ||
'Access-Control-Allow-Headers', | ||
req.headers['access-control-request-headers'] || '' | ||
) | ||
|
||
if (req.method === 'OPTIONS') { | ||
res.writeHead(200) | ||
res.end() | ||
return | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(`[QLI-API-DEV-PROXY] - API CALL - [${req.method}] ${options.target}${req.url}`) | ||
proxyReq.setHeader('Authorization', req.headers.authorization || '') | ||
}) | ||
|
||
proxy.on('error', (err, _req, res) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Proxy error: ${err.message}`) | ||
res.writeHead(500, { 'Content-Type': 'application/json' }) | ||
res.end(JSON.stringify({ error: 'Proxy error', details: err.message })) | ||
}) | ||
export const createProxyConfig = ( | ||
target: string, | ||
rewritePath: string, | ||
label = 'PROXY' | ||
): ProxyOptions => { | ||
return { | ||
target, | ||
changeOrigin: true, | ||
rewrite: (path: string) => path.replace(rewritePath, ''), | ||
configure: (proxy: HttpProxy.Server, options: ProxyOptions) => { | ||
proxy.on('proxyReq', (proxyReq, req, res) => { | ||
res.setHeader('Access-Control-Allow-Origin', '*') | ||
res.setHeader('Access-Control-Allow-Methods', 'GET, PUT, PATCH, POST, DELETE') | ||
res.setHeader( | ||
'Access-Control-Allow-Headers', | ||
req.headers['access-control-request-headers'] || '' | ||
) | ||
|
||
if (req.method === 'OPTIONS') { | ||
res.writeHead(200) | ||
res.end() | ||
return | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(`[${label}] - API CALL - [${req.method}] ${options.target}${req.url}`) | ||
proxyReq.setHeader('Authorization', req.headers.authorization || '') | ||
}) | ||
|
||
proxy.on('error', (err, _req, res) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Proxy error: ${err.message}`) | ||
res.writeHead(500, { 'Content-Type': 'application/json' }) | ||
res.end(JSON.stringify({ error: 'Proxy error', details: err.message })) | ||
}) | ||
} | ||
} | ||
} | ||
|
||
export const archiverApiProxy: ProxyOptions = { | ||
target: 'https://rpc.qubic.org/v1', | ||
changeOrigin: true, | ||
rewrite: (path: string) => path.replace(/^\/dev-proxy-archiver-api/, ''), | ||
configure: (proxy: HttpProxy.Server, options: ProxyOptions) => { | ||
proxy.on('proxyReq', (proxyReq, req, res) => { | ||
res.setHeader('Access-Control-Allow-Origin', '*') | ||
res.setHeader('Access-Control-Allow-Methods', 'GET, PUT, PATCH, POST, DELETE') | ||
res.setHeader( | ||
'Access-Control-Allow-Headers', | ||
req.headers['access-control-request-headers'] || '' | ||
) | ||
|
||
if (req.method === 'OPTIONS') { | ||
res.writeHead(200) | ||
res.end() | ||
return | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.log( | ||
`[ARCHIVER-API-DEV-PROXY] - API CALL - [${req.method}] ${options.target}${req.url}` | ||
) | ||
proxyReq.setHeader('Authorization', req.headers.authorization || '') | ||
}) | ||
|
||
proxy.on('error', (err, _req, res) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Proxy error: ${err.message}`) | ||
res.writeHead(500, { 'Content-Type': 'application/json' }) | ||
res.end(JSON.stringify({ error: 'Proxy error', details: err.message })) | ||
}) | ||
} | ||
} | ||
export const qliApiProxy = createProxyConfig( | ||
'https://api.qubic.li', | ||
'/dev-proxy-qli-api', | ||
'QLI-API-DEV-PROXY' | ||
) | ||
export const archiverApiProxy = createProxyConfig( | ||
'https://rpc.qubic.org', | ||
'/dev-proxy-archiver-api', | ||
'ARCHIVER-API-DEV-PROXY' | ||
) |
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
Oops, something went wrong.