Skip to content

Commit

Permalink
Rename withApiKey to withLegacyApiKey
Browse files Browse the repository at this point in the history
The v2 API passes the key in the payload.
  • Loading branch information
swansontec committed Aug 5, 2022
1 parent caf06b9 commit 0121844
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { errorResponse } from '../types/responseTypes'
* Checks the API key passed in the request headers,
* then passes the request along if the key is valid.
*/
export const withApiKey =
export const withLegacyApiKey =
(server: Serverlet<ApiRequest>): Serverlet<DbRequest> =>
async request => {
const { connection, headers, log } = request
Expand Down
18 changes: 9 additions & 9 deletions src/server/urls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pickMethod, pickPath, Serverlet } from 'serverlet'

import { withApiKey } from '../middleware/withApiKey'
import { withLegacyApiKey } from '../middleware/withLegacyApiKey'
import {
attachUserV1Route,
enableCurrencyV1Route,
Expand All @@ -23,29 +23,29 @@ const urls: { [path: string]: Serverlet<DbRequest> } = {
'/': healthCheckRoute,

'/v1/device/?': pickMethod({
POST: withApiKey(registerDeviceV1Route)
POST: withLegacyApiKey(registerDeviceV1Route)
}),

'/v1/notification/send/?': pickMethod({
POST: withApiKey(sendNotificationV1Route)
POST: withLegacyApiKey(sendNotificationV1Route)
}),

// The GUI accesses `/v1//user?userId=...` with an extra `/`:
'/v1/+user/?': pickMethod({
GET: withApiKey(fetchStateV1Route)
GET: withLegacyApiKey(fetchStateV1Route)
}),
'/v1/user/device/attach/?': pickMethod({
POST: withApiKey(attachUserV1Route)
POST: withLegacyApiKey(attachUserV1Route)
}),
'/v1/user/notifications/?': pickMethod({
POST: withApiKey(registerCurrenciesV1Route)
POST: withLegacyApiKey(registerCurrenciesV1Route)
}),
'/v1/user/notifications/toggle/?': pickMethod({
POST: withApiKey(toggleStateV1Route)
POST: withLegacyApiKey(toggleStateV1Route)
}),
'/v1/user/notifications/[0-9A-Za-z]+/?': pickMethod({
GET: withApiKey(fetchCurrencyV1Route),
PUT: withApiKey(enableCurrencyV1Route)
GET: withLegacyApiKey(fetchCurrencyV1Route),
PUT: withLegacyApiKey(enableCurrencyV1Route)
})
}
export const allRoutes: Serverlet<DbRequest> = pickPath(urls, missingRoute)

0 comments on commit 0121844

Please sign in to comment.