mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
17 lines
406 B
TypeScript
17 lines
406 B
TypeScript
import { Injectable, NestMiddleware } from '@nestjs/common';
|
|
|
|
export const LOCALE_KEY = 'locale';
|
|
|
|
@Injectable()
|
|
export class LocaleMiddleware implements NestMiddleware {
|
|
use(req: any, res: any, next: () => void) {
|
|
const locale =
|
|
req.query.lang as string ||
|
|
req.headers['accept-language']?.split(',')[0]?.split('-')[0] ||
|
|
'en';
|
|
|
|
req[LOCALE_KEY] = locale;
|
|
next();
|
|
}
|
|
}
|