11import express from 'express'
22import http from 'http'
3- import { pickMethod , pickPath } from 'serverlet'
3+ import { pickMethod , pickPath , withCors } from 'serverlet'
44import { makeExpressRoute } from 'serverlet/express'
55
66import { config } from '../config'
@@ -18,15 +18,17 @@ async function main(): Promise<void> {
1818}
1919
2020function server ( ) : void {
21- const server = pickPath ( {
22- '/' : pickMethod ( { GET : heartbeatV3 } ) ,
23- '/v2/exchangeRate' : pickMethod ( { GET : rateV2 } ) ,
24- '/v2/exchangeRates' : pickMethod ( { POST : ratesV2 } ) ,
25- '/v2/coinrank' : pickMethod ( { GET : sendCoinranksV2 } ) ,
26- '/v2/coinrankAsset/([^/]+)' : pickMethod ( { GET : sendCoinrankAssetV2 } ) ,
27- '/v2/coinrankList' : pickMethod ( { GET : sendCoinrankListV2 } ) ,
28- '/v3/rates' : pickMethod ( { POST : ratesV3 } )
29- } )
21+ const server = withCors (
22+ pickPath ( {
23+ '/' : pickMethod ( { GET : heartbeatV3 } ) ,
24+ '/v2/exchangeRate' : pickMethod ( { GET : rateV2 } ) ,
25+ '/v2/exchangeRates' : pickMethod ( { POST : ratesV2 } ) ,
26+ '/v2/coinrank' : pickMethod ( { GET : sendCoinranksV2 } ) ,
27+ '/v2/coinrankAsset/([^/]+)' : pickMethod ( { GET : sendCoinrankAssetV2 } ) ,
28+ '/v2/coinrankList' : pickMethod ( { GET : sendCoinrankListV2 } ) ,
29+ '/v3/rates' : pickMethod ( { POST : ratesV3 } )
30+ } )
31+ )
3032
3133 // Set up Express:
3234 const app = express ( )
0 commit comments