Skip to content

Commit be885c9

Browse files
committed
Allow cors
1 parent ab1ee43 commit be885c9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/v3/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import express from 'express'
22
import http from 'http'
3-
import { pickMethod, pickPath } from 'serverlet'
3+
import { pickMethod, pickPath, withCors } from 'serverlet'
44
import { makeExpressRoute } from 'serverlet/express'
55

66
import { config } from '../config'
@@ -18,15 +18,17 @@ async function main(): Promise<void> {
1818
}
1919

2020
function 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

Comments
 (0)