(core) Converting server-side Comm.js to typescript

Summary:
- Add app/common/CommTypes.ts to define types shared by client and server.
- Include @types/ws npm package

Test Plan: Intended to have no changes in behavior

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3467
This commit is contained in:
Dmitry S
2022-06-04 00:12:30 -04:00
parent 519f1be93a
commit 4f1cb53b29
23 changed files with 655 additions and 716 deletions

View File

@@ -1,12 +1,12 @@
import {parse as languageParser} from "accept-language-parser";
import {Request} from 'express';
import {IncomingMessage} from 'http';
import {locales} from 'app/common/Locales';
/**
* Returns the locale from a request, falling back to `defaultLocale`
* if unable to determine the locale.
*/
export function localeFromRequest(req: Request, defaultLocale: string = 'en-US') {
export function localeFromRequest(req: IncomingMessage, defaultLocale: string = 'en-US') {
const language = languageParser(req.headers["accept-language"] as string)[0];
if (!language) { return defaultLocale; }