Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/server/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

import express from 'express';
import express, {Router} from 'express';
import expressSitemapXml from 'express-sitemap-xml';
import hbs from 'hbs';
import helmet from 'helmet';
Expand All @@ -30,8 +30,10 @@ import https from 'https';
import path from 'path';

import type {ClientConfig, ServerConfig} from '@wireapp/config';

import {HealthCheckRoute} from './routes/_health/HealthRoute';
import {AppleAssociationRoute} from './routes/appleassociation/AppleAssociationRoute';
import {createClientVersionCheckRoute} from './routes/client-version-check/ClientVersionCheckRoute';
import {ConfigRoute} from './routes/config/ConfigRoute';
import {InternalErrorRoute, NotFoundRoute} from './routes/error/ErrorRoutes';
import {GoogleWebmasterRoute} from './routes/googlewebmaster/GoogleWebmasterRoute';
Expand Down Expand Up @@ -67,7 +69,7 @@ class Server {
this.initStaticRoutes();
this.initWebpack();
this.initSiteMap(this.config);
// eslint-disable-next-line import/no-named-as-default-member

this.app.use('/libs', express.static(path.join(__dirname, 'libs')));
this.app.use(Root());
this.app.use(HealthCheckRoute());
Expand All @@ -76,6 +78,7 @@ class Server {
this.app.use(AppleAssociationRoute());
this.app.use(NotFoundRoute());
this.app.use(InternalErrorRoute());
this.app.use(createClientVersionCheckRoute({router: Router()}));
Comment on lines 79 to +81
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Blocker] - /client-version-check is registered after NotFoundRoute() and InternalErrorRoute(), so it will never be reached.

NotFoundRoute() registers a GET * handler (apps/server/routes/error/ErrorRoutes.ts:53-68) which will match /client-version-check first and return a 404 error page. Move createClientVersionCheckRoute(...) above NotFoundRoute() (and keep not-found / error handlers last).

Suggested change
this.app.use(NotFoundRoute());
this.app.use(InternalErrorRoute());
this.app.use(createClientVersionCheckRoute({router: Router()}));
this.app.use(createClientVersionCheckRoute({router: Router()}));
this.app.use(NotFoundRoute());
this.app.use(InternalErrorRoute());

Copilot uses AI. Check for mistakes.
}

private initWebpack() {
Expand Down Expand Up @@ -170,7 +173,6 @@ class Server {
const staticRoutes = ['audio', 'ext', 'font', 'image', 'min', 'proto', 'style', 'worker', 'assets'];

staticRoutes.forEach(route => {
// eslint-disable-next-line import/no-named-as-default-member
this.app.use(`/${route}`, express.static(path.join(__dirname, `static/${route}`)));
});

Expand Down
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
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] - Route factory signature is inconsistent with the surrounding route style.

Most existing routes export XRoute = (...) => Router().get(...) and construct their own router (e.g. HealthCheckRoute, AppleAssociationRoute, ConfigRoute). Consider following the same pattern here (instead of injecting router), which would simplify usage in Server.ts and keep route registration consistent.

Copilot uses AI. Check for mistakes.

return router.get('/client-version-check', (request, response) => {
return response.sendStatus(HTTP_STATUS.OK);
Comment on lines +30 to +31
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Important] - Unused request parameter will trigger @typescript-eslint/no-unused-vars warnings.

Other routes use _req/_request for unused parameters (e.g. AppleAssociationRoute, RedirectRoutes). Consider renaming request to _request (or _req) here to match the repo’s lint expectations.

Copilot uses AI. Check for mistakes.
});
}
Loading