* trpc procedures an middleware refactor * allow use sessionMiddleware without a req object * sync with the new tRPC structure * tRPC refactor on routing form app * import Prisma from @prisma/client * Lazy load apps from appstore * remove unrelated changes * Add types for PaymentService * type fixes * Merge branch 'main' into roae85/cal-1514-set-the-user-session-only-on-the * fix typo * remove console.log * remove explicit types from apstore object * linter fixes --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
20 lines
564 B
TypeScript
20 lines
564 B
TypeScript
import sessionMiddleware from "./sessionMiddleware";
|
|
|
|
const localeMiddleware = sessionMiddleware.unstable_pipe(async ({ ctx, next }) => {
|
|
const { serverSideTranslations } = await import("next-i18next/serverSideTranslations");
|
|
const { user } = ctx;
|
|
|
|
const i18n = await serverSideTranslations(
|
|
user?.locale && user?.locale !== ctx.locale ? user.locale : ctx.locale,
|
|
["common", "vital"]
|
|
);
|
|
|
|
const locale = user?.locale || ctx.locale;
|
|
|
|
return next({
|
|
ctx: { locale, i18n, user: { ...user, locale } },
|
|
});
|
|
});
|
|
|
|
export default localeMiddleware;
|