Skip to content

Commit

Permalink
fix(adapter): add support for async load context
Browse files Browse the repository at this point in the history
  • Loading branch information
lfantone committed Jan 11, 2024
1 parent 1112635 commit 1a923d5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
13 changes: 3 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# 1.0.0 (2024-01-11)


### Bug Fixes

* **deps:** upgrade node dependencies 73e74c2
* **remix-adapter:** update jsdocs and types da375a7

- **deps:** upgrade node dependencies 73e74c2
- **remix-adapter:** update jsdocs and types da375a7

### Features

* **adapter:** implement remix.run azure adapter 1cdaa77
* **create-remix-azure-adapter:** support asynchronous getLoadContext f1503b3
* **create-remix-azure-adapter:** support asynchronous getLoadContext 90da3a2
* **packages:** add the create-remix-azure-adapter package ([#58](https://github.com/scandinavianairlines/remix-azure-functions/issues/58)) 033c5ce
* **rename:** remove 'adg' prefix from package name c197b97
* **types:** generate types on pre-publish 6ea55aa
- **adapter:** implement remix.run azure adapter 1cdaa77
4 changes: 2 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { isBinaryType } from './is-binary-type.js';
installGlobals();

/**
* @typedef {(request: import('@azure/functions').HttpRequest, context: import('@azure/functions').InvocationContext) => import('@remix-run/node').AppLoadContext} GetLoadContextFn
* @typedef {(request: import('@azure/functions').HttpRequest, context: import('@azure/functions').InvocationContext) => Promise<import('@remix-run/node').AppLoadContext>} GetLoadContextFn
*/

/**
Expand Down Expand Up @@ -98,7 +98,7 @@ export function createRequestHandler(options) {
* @returns {Promise<import('@azure/functions').HttpResponseInit>} A Azure Function `http response init` object.
*/
async function functionHandler(request, context) {
const loadContext = options.getLoadContext?.(request, context);
const loadContext = await options.getLoadContext?.(request, context);
const remixRequest = createRemixRequest(request, { urlParser: options.urlParser });
const remixResponse = await handler(remixRequest, loadContext);

Expand Down
2 changes: 1 addition & 1 deletion src/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('server', () => {
params: undefined,
url: 'https://test.com',
});
const mockGetLoadContext = vi.fn();
const mockGetLoadContext = vi.fn().mockResolvedValue({});
const mockAzureContext = { log: vi.fn() };
createRemixRequestHandler.mockReturnValue(mockHandler);
const handler = createRequestHandler({
Expand Down

0 comments on commit 1a923d5

Please sign in to comment.