-
Notifications
You must be signed in to change notification settings - Fork 297
feat(server): create client-version-check route [WPB-23299] #20307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import {Router, type Response} from 'express'; | ||
| import {createClientVersionCheckRoute} from './ClientVersionCheckRoute'; | ||
|
|
||
| describe('/client-version-check', () => { | ||
| it('listens on /client-version-check path', async () => { | ||
| const fakeGet = jest.fn(); | ||
|
|
||
| const fakeRouter = { | ||
| get: fakeGet, | ||
| } as unknown as Router; | ||
|
|
||
| createClientVersionCheckRoute({router: fakeRouter}); | ||
|
|
||
| expect(fakeGet).toHaveBeenNthCalledWith(1, '/client-version-check', expect.any(Function)); | ||
| }); | ||
|
|
||
| it('returns HTTP 200', async () => { | ||
| const sendStatus = jest.fn(); | ||
| const fakeResponse = {sendStatus} as unknown as Response; | ||
|
|
||
| const fakeRouter = { | ||
| get: jest.fn((_routePath, routeHandler) => { | ||
| routeHandler(undefined, fakeResponse); | ||
| }), | ||
| } as unknown as Router; | ||
|
|
||
| createClientVersionCheckRoute({router: fakeRouter}); | ||
|
|
||
| expect(sendStatus).toHaveBeenNthCalledWith(1, 200); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Wire | ||
| * Copyright (C) 2026 Wire Swiss GmbH | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see http://www.gnu.org/licenses/. | ||
| * | ||
| */ | ||
|
|
||
| import {Router} from 'express'; | ||
| import {StatusCodes as HTTP_STATUS} from 'http-status-codes'; | ||
|
|
||
| type ClientVersionCheckRouteDependencies = { | ||
| readonly router: ReturnType<typeof Router>; | ||
| }; | ||
|
|
||
| export function createClientVersionCheckRoute(dependencies: ClientVersionCheckRouteDependencies) { | ||
| const {router} = dependencies; | ||
|
Comment on lines
+23
to
+28
|
||
|
|
||
| return router.get('/client-version-check', (request, response) => { | ||
| return response.sendStatus(HTTP_STATUS.OK); | ||
|
Comment on lines
+30
to
+31
|
||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Blocker] -
/client-version-checkis registered afterNotFoundRoute()andInternalErrorRoute(), so it will never be reached.NotFoundRoute()registers a GET*handler (apps/server/routes/error/ErrorRoutes.ts:53-68) which will match/client-version-checkfirst and return a 404 error page. MovecreateClientVersionCheckRoute(...)aboveNotFoundRoute()(and keep not-found / error handlers last).