29 lines
785 B
TypeScript
29 lines
785 B
TypeScript
import {
|
|
createMintelDirectusClient,
|
|
ensureDirectusAuthenticated,
|
|
} from "@mintel/next-utils";
|
|
import { getServerAppServices } from "./services/create-services.server";
|
|
|
|
// Initialize client using Mintel standards (environment-aware)
|
|
const client = createMintelDirectusClient();
|
|
|
|
/**
|
|
* Ensures the client is authenticated.
|
|
* Standardized using @mintel/next-utils ensureDirectusAuthenticated.
|
|
*/
|
|
export async function ensureAuthenticated() {
|
|
try {
|
|
await ensureDirectusAuthenticated(client);
|
|
} catch (e) {
|
|
if (typeof window === "undefined") {
|
|
getServerAppServices().errors.captureException(e, {
|
|
phase: "directus_auth_standardized",
|
|
});
|
|
}
|
|
console.error("Failed to authenticate with Directus:", e);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
export default client;
|