Skip to content

Commit 3e8d65b

Browse files
authored
add new endpoint (#189)
1 parent e7af40c commit 3e8d65b

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

.env.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ ADMIN_USERNAME=
1212
ADMIN_PASSWORD=
1313
TEMPLE_TAP_API_URL=
1414
EVM_API_URL=
15+
WERT_API_KEY=

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const EnvVars = {
1414
ADMIN_USERNAME: getEnv('ADMIN_USERNAME'),
1515
ADMIN_PASSWORD: getEnv('ADMIN_PASSWORD'),
1616
TEMPLE_TAP_API_URL: getEnv('TEMPLE_TAP_API_URL'),
17-
EVM_API_URL: getEnv('EVM_API_URL')
17+
EVM_API_URL: getEnv('EVM_API_URL'),
18+
WERT_API_KEY: getEnv('WERT_API_KEY')
1819
};
1920

2021
for (const name in EnvVars) {

src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import logger from './utils/logger';
4343
import { getSignedMoonPayUrl } from './utils/moonpay/get-signed-moonpay-url';
4444
import SingleQueryDataProvider from './utils/SingleQueryDataProvider';
4545
import { getExchangeRates } from './utils/tokens';
46+
import { getWertSessionId } from './utils/wert';
4647

4748
const PINO_LOGGER = {
4849
logger: logger.child({ name: 'web' }),
@@ -398,6 +399,20 @@ app.get('/api/signing-nonce', (req, res) => {
398399
}
399400
});
400401

402+
app.get('/api/wert-session-id', async (_, res) => {
403+
try {
404+
res.status(200).send(await getWertSessionId());
405+
} catch (error: any) {
406+
console.error(error);
407+
408+
if (error instanceof CodedError) {
409+
res.status(error.code).send(error.buildResponse());
410+
} else {
411+
res.status(500).send({ message: error?.message });
412+
}
413+
}
414+
});
415+
401416
app.post('/api/temple-tap/confirm-airdrop-username', tezosSigAuthMiddleware, (req, res) =>
402417
handleTempleTapApiProxyRequest(req, res, 'v1/confirm-airdrop-address')
403418
);

src/utils/wert.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import axios from 'axios';
2+
3+
import { EnvVars } from '../config';
4+
5+
interface SessionResponse {
6+
sessionId: string;
7+
requestId: string;
8+
}
9+
10+
/** https://docs.wert.io/docs/fiat-onramp */
11+
export const getWertSessionId = () =>
12+
axios
13+
.post<SessionResponse>(
14+
'https://partner.wert.io/api/external/hpp/create-session',
15+
{ flow_type: 'simple' },
16+
{
17+
headers: {
18+
'X-Api-Key': EnvVars.WERT_API_KEY,
19+
'Content-Type': 'application/json'
20+
}
21+
}
22+
)
23+
.then(res => res.data.sessionId);

0 commit comments

Comments
 (0)