This repository has been archived by the owner on May 15, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite to typescript (relayer: [middlewares, routes]) (#410)
* Rewrite to typescript (relayer: [middlewares, routes]) * Change AuthorisationRequest type on external types * Extract define Type
- Loading branch information
1 parent
66559f0
commit de865de
Showing
9 changed files
with
121 additions
and
49 deletions.
There are no files selected for viewing
9 changes: 6 additions & 3 deletions
9
...ersal-login-relayer/lib/config/relayer.js → ...ersal-login-relayer/lib/config/relayer.ts
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,13 +1,16 @@ | ||
require('dotenv').config(); | ||
|
||
module.exports = Object.freeze({ | ||
const config = Object.freeze({ | ||
legacyENS: true, | ||
jsonRpcUrl: process.env.JSON_RPC_URL, | ||
port: process.env.PORT, | ||
privateKey: process.env.PRIVATE_KEY, | ||
chainSpec: { | ||
chainSpec: Object.freeze({ | ||
ensAddress: process.env.ENS_ADDRESS, | ||
chainId: 0, | ||
}, | ||
}), | ||
ensRegistrars: [process.env.ENS_DOMAIN_1, process.env.ENS_DOMAIN_2, process.env.ENS_DOMAIN_3], | ||
}); | ||
|
||
export type Config = typeof config; | ||
export type ChainSpecConfig = Config['chainSpec']; |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
import {Request, Response, NextFunction} from 'express'; | ||
|
||
const asyncMiddleware = (fn : Function) => | ||
(req : Request, res : Response, next : NextFunction) => { | ||
Promise.resolve(fn(req, res, next)) | ||
.catch(next); | ||
}; | ||
|
||
export default asyncMiddleware; |
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 was deleted.
Oops, something went wrong.
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,20 @@ | ||
import {Router, Request, Response} from 'express'; | ||
import asyncMiddleware from '../middlewares/async_middleware'; | ||
import {ChainSpecConfig} from '../config/relayer'; | ||
|
||
|
||
|
||
export const network = (config : ChainSpecConfig) => async (req : Request, res : Response) => { | ||
res.status(200) | ||
.type('json') | ||
.send(JSON.stringify({config})); | ||
}; | ||
|
||
export default (config : ChainSpecConfig) => { | ||
const router = Router(); | ||
|
||
router.get('/', | ||
asyncMiddleware(network(config))); | ||
|
||
return router; | ||
}; |
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