Files
myeasycms-v2/apps/web/lib/i18n/i18n.resolver.ts
Giancarlo Buomprisco e193c94f06 Cookies validation and Security Guidelines (#242)
* Add OTP and security guidelines documentation and additional checks on client-provided values

- Introduced additional checks on client-provided values such as cookies
- Introduced a new OTP API documentation outlining the creation and verification of OTP tokens for sensitive operations.
- Added comprehensive security guidelines for writing secure code in Next.js, covering client and server components, environment variables, authentication, and error handling.

These additions enhance the project's security posture and provide clear instructions for developers on implementing secure practices.

* Add OTP API documentation and enhance security guidelines

- Introduced comprehensive documentation for the OTP API, detailing the creation and verification of OTP tokens for sensitive operations.
- Enhanced security guidelines for Next.js, emphasizing the importance of input validation, environment variable management, and error handling.
- Implemented additional checks for client-provided values to improve overall security posture.

These updates provide clear instructions for developers and strengthen the project's security framework.
2025-04-22 06:44:55 +08:00

32 lines
929 B
TypeScript

import { getLogger } from '@kit/shared/logger';
/**
* @name i18nResolver
* @description Resolve the translation file for the given language and namespace in the current application.
* @param language
* @param namespace
*/
export async function i18nResolver(language: string, namespace: string) {
const logger = await getLogger();
try {
const data = await import(
`../../public/locales/${language}/${namespace}.json`
);
return data as Record<string, string>;
} catch (error) {
console.group(
`Error while loading translation file: ${language}/${namespace}`,
);
logger.error(error instanceof Error ? error.message : error);
logger.warn(
`Please create a translation file for this language at "public/locales/${language}/${namespace}.json"`,
);
console.groupEnd();
// return an empty object if the file could not be loaded to avoid loops
return {};
}
}