diff --git a/apps/server/Server.ts b/apps/server/Server.ts index ee14f622b21..c291e7902d0 100644 --- a/apps/server/Server.ts +++ b/apps/server/Server.ts @@ -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'; @@ -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'; @@ -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()); @@ -76,6 +78,7 @@ class Server { this.app.use(AppleAssociationRoute()); this.app.use(NotFoundRoute()); this.app.use(InternalErrorRoute()); + this.app.use(createClientVersionCheckRoute({router: Router()})); } private initWebpack() { @@ -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}`))); }); diff --git a/apps/server/routes/client-version-check/ClientVersionCheckRoute.test.ts b/apps/server/routes/client-version-check/ClientVersionCheckRoute.test.ts new file mode 100644 index 00000000000..f4175bb8a73 --- /dev/null +++ b/apps/server/routes/client-version-check/ClientVersionCheckRoute.test.ts @@ -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); + }); +}); diff --git a/apps/server/routes/client-version-check/ClientVersionCheckRoute.ts b/apps/server/routes/client-version-check/ClientVersionCheckRoute.ts new file mode 100644 index 00000000000..d0ffb35ae4a --- /dev/null +++ b/apps/server/routes/client-version-check/ClientVersionCheckRoute.ts @@ -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; +}; + +export function createClientVersionCheckRoute(dependencies: ClientVersionCheckRouteDependencies) { + const {router} = dependencies; + + return router.get('/client-version-check', (request, response) => { + return response.sendStatus(HTTP_STATUS.OK); + }); +}