[ci] format
This commit is contained in:
parent
0ddcef2043
commit
a4c78b544e
3 changed files with 8 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
|
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
|
||||||
import { createRedirects } from './shared.js';
|
|
||||||
import type { Args } from './netlify-functions.js';
|
import type { Args } from './netlify-functions.js';
|
||||||
|
import { createRedirects } from './shared.js';
|
||||||
|
|
||||||
export function getAdapter(args: Args = {}): AstroAdapter {
|
export function getAdapter(args: Args = {}): AstroAdapter {
|
||||||
return {
|
return {
|
||||||
|
@ -16,7 +16,10 @@ interface NetlifyFunctionsOptions {
|
||||||
binaryMediaTypes?: string[];
|
binaryMediaTypes?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function netlifyFunctions({ dist, binaryMediaTypes }: NetlifyFunctionsOptions = {}): AstroIntegration {
|
function netlifyFunctions({
|
||||||
|
dist,
|
||||||
|
binaryMediaTypes,
|
||||||
|
}: NetlifyFunctionsOptions = {}): AstroIntegration {
|
||||||
let _config: AstroConfig;
|
let _config: AstroConfig;
|
||||||
let entryFile: string;
|
let entryFile: string;
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -73,14 +73,14 @@ export const createExports = (manifest: SSRManifest, args: Args) => {
|
||||||
|
|
||||||
const response: Response = await app.render(request);
|
const response: Response = await app.render(request);
|
||||||
const responseHeaders = Object.fromEntries(response.headers.entries());
|
const responseHeaders = Object.fromEntries(response.headers.entries());
|
||||||
|
|
||||||
const responseContentType = parseContentType(responseHeaders['content-type']);
|
const responseContentType = parseContentType(responseHeaders['content-type']);
|
||||||
const responseIsBase64Encoded = knownBinaryMediaTypes.has(responseContentType);
|
const responseIsBase64Encoded = knownBinaryMediaTypes.has(responseContentType);
|
||||||
|
|
||||||
const responseBody = responseIsBase64Encoded
|
const responseBody = responseIsBase64Encoded
|
||||||
? Buffer.from(await response.text(), 'binary').toString('base64')
|
? Buffer.from(await response.text(), 'binary').toString('base64')
|
||||||
: await response.text();
|
: await response.text();
|
||||||
|
|
||||||
const fnResponse: any = {
|
const fnResponse: any = {
|
||||||
statusCode: response.status,
|
statusCode: response.status,
|
||||||
headers: responseHeaders,
|
headers: responseHeaders,
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('Base64 Responses', () => {
|
||||||
},
|
},
|
||||||
adapter: netlifyAdapter({
|
adapter: netlifyAdapter({
|
||||||
dist: new URL('./fixtures/base64-response/dist/', import.meta.url),
|
dist: new URL('./fixtures/base64-response/dist/', import.meta.url),
|
||||||
binaryMediaTypes: ['font/otf']
|
binaryMediaTypes: ['font/otf'],
|
||||||
}),
|
}),
|
||||||
site: `http://example.com`,
|
site: `http://example.com`,
|
||||||
integrations: [testIntegration()],
|
integrations: [testIntegration()],
|
||||||
|
|
Loading…
Reference in a new issue