Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions netlify/functions/api.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { getStore } from '@netlify/blobs';
import { createApi } from '../../src/api.js';

let api;
// Netlify v2 request handler; state is persisted in strongly consistent Blobs.
// Netlify v2 request handler; refresh request-scoped Blob credentials on every invocation.
export default async function handler(request) {
api ||= createApi({ store: getStore('releasecue', { consistency: 'strong' }) });
return api(request);
return createApi({ store: getStore('releasecue', { consistency: 'strong' }) })(request);
}
6 changes: 6 additions & 0 deletions test/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { join } from 'node:path';
import { tmpdir } from 'node:os';
import { build } from '../scripts/build.mjs';

test('function refreshes the request-scoped Blob client instead of caching expiring credentials', async () => {
const wrapper = await readFile(new URL('../netlify/functions/api.mjs', import.meta.url), 'utf8');
assert.doesNotMatch(wrapper, /api\s*\|\|=/);
assert.match(wrapper, /createApi\(\{ store: getStore\('releasecue', \{ consistency: 'strong' \}\) \}\)\(request\)/);
});

test('client ships onboarding, persistent dashboard, and release action surfaces with recovery states', async () => {
const [html, app, config] = await Promise.all([
readFile(new URL('../public/index.html', import.meta.url), 'utf8'),
Expand Down