Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
924 B
Text
25 lines
924 B
Text
import { getExtendedInstanceMetadataCredentials } from "./getExtendedInstanceMetadataCredentials";
|
|
export const staticStabilityProvider = (provider, options = {}) => {
|
|
const logger = options?.logger || console;
|
|
let pastCredentials;
|
|
return async () => {
|
|
let credentials;
|
|
try {
|
|
credentials = await provider();
|
|
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
|
|
credentials = getExtendedInstanceMetadataCredentials(credentials, logger);
|
|
}
|
|
}
|
|
catch (e) {
|
|
if (pastCredentials) {
|
|
logger.warn("Credential renew failed: ", e);
|
|
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);
|
|
}
|
|
else {
|
|
throw e;
|
|
}
|
|
}
|
|
pastCredentials = credentials;
|
|
return credentials;
|
|
};
|
|
};
|