diff --git a/src/middleware/withApiKey.ts b/src/middleware/withLegacyApiKey.ts similarity index 96% rename from src/middleware/withApiKey.ts rename to src/middleware/withLegacyApiKey.ts index be3d61b..9454d8e 100644 --- a/src/middleware/withApiKey.ts +++ b/src/middleware/withLegacyApiKey.ts @@ -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): Serverlet => async request => { const { connection, headers, log } = request diff --git a/src/server/urls.ts b/src/server/urls.ts index 403f5b1..d88d1bb 100644 --- a/src/server/urls.ts +++ b/src/server/urls.ts @@ -1,6 +1,6 @@ import { pickMethod, pickPath, Serverlet } from 'serverlet' -import { withApiKey } from '../middleware/withApiKey' +import { withLegacyApiKey } from '../middleware/withLegacyApiKey' import { attachUserV1Route, enableCurrencyV1Route, @@ -23,29 +23,29 @@ const urls: { [path: string]: Serverlet } = { '/': 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 = pickPath(urls, missingRoute)