Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: testing #6

Merged
merged 1 commit into from
Apr 27, 2024
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
34 changes: 34 additions & 0 deletions .github/workflows/testingci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Testing CI

on:
pull_request:
branches: ['*']

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: TSC
run: pnpm run check

- name: Prettier
run: pnpm run check-format

- name: ESLint
run: pnpm run lint
6 changes: 4 additions & 2 deletions cloudfront/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export type CloudFrontFunctionsEvent = import("aws-lambda").CloudFrontFunctionsEvent;
export type CloudFrontFunctionsQuerystring = import("aws-lambda").CloudFrontFunctionsQuerystring;
export type CloudFrontFunctionsEvent =
import('aws-lambda').CloudFrontFunctionsEvent;
export type CloudFrontFunctionsQuerystring =
import('aws-lambda').CloudFrontFunctionsQuerystring;
6 changes: 4 additions & 2 deletions cloudfront/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */

/**
* @typedef {import("aws-lambda").CloudFrontFunctionsEvent} CloudFrontFunctionsEvent
* @typedef {import("aws-lambda").CloudFrontFunctionsQuerystring} CloudFrontFunctionsQuerystring
Expand All @@ -7,8 +9,8 @@
* Note: form action requests contain "/" in request query string
* ie. POST request with query string "?/action"
* CloudFront does not allow query string with "/". It needs to be encoded.
* @param {CloudFrontFunctionsEvent} event
* @returns {any}
* @param {CloudFrontFunctionsEvent} event - Cloudfront functions event
* @returns {any} - Cloudfront function event request
*/
function handler(event) {
var request = event.request;
Expand Down
137 changes: 77 additions & 60 deletions handler/event-mapper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,93 +23,110 @@
* @param {any} event The event to check.
* @returns {event is APIGatewayProxyEventV2} True if it's an API Gateway V2 event.
*/
export function isAPIGatewayProxyEventV2(event: any): event is import("aws-lambda").APIGatewayProxyEventV2;
export function isAPIGatewayProxyEventV2(
event: any
): event is import('aws-lambda').APIGatewayProxyEventV2;
/**
* Checks if the event is an API Gateway V1 event.
* @param {any} event The event to check.
* @returns {event is APIGatewayProxyEvent} True if it's an API Gateway V1 event.
*/
export function isAPIGatewayProxyEvent(event: any): event is import("aws-lambda").APIGatewayProxyEvent;
export function isAPIGatewayProxyEvent(
event: any
): event is import('aws-lambda').APIGatewayProxyEvent;
/**
* Checks if the event is a CloudFront request event.
* @param {any} event The event to check.
* @returns {event is CloudFrontRequestEvent} True if it's a CloudFront request event.
*/
export function isCloudFrontRequestEvent(event: any): event is import("aws-lambda").CloudFrontRequestEvent;
export function isCloudFrontRequestEvent(
event: any
): event is import('aws-lambda').CloudFrontRequestEvent;
/**
* Converts an API Gateway or CloudFront event to an internal event format.
* @param {APIGatewayProxyEventV2|APIGatewayProxyEvent|CloudFrontRequestEvent} event The event to convert.
* @returns {InternalEvent} The internal event.
*/
export function convertFrom(event: import("aws-lambda").APIGatewayProxyEventV2 | import("aws-lambda").APIGatewayProxyEvent | CloudFrontRequestEvent): InternalEvent;
export function convertFrom(
event:
| import('aws-lambda').APIGatewayProxyEventV2
| import('aws-lambda').APIGatewayProxyEvent
| CloudFrontRequestEvent
): InternalEvent;
/**
* Converts an internal result to a corresponding AWS API Gateway or CloudFront result.
* @param {InternalResult} result The internal result to convert.
* @returns {APIGatewayProxyResultV2|APIGatewayProxyResult|CloudFrontRequestResult} The API Gateway or CloudFront result.
*/
export function convertTo(result: InternalResult): APIGatewayProxyResultV2 | APIGatewayProxyResult | CloudFrontRequestResult;
export function convertTo(
result: InternalResult
): APIGatewayProxyResultV2 | APIGatewayProxyResult | CloudFrontRequestResult;
/**
* Represents an internal event type.
*/
export type InternalEvent = {
/**
* The type of the event.
*/
type: "v1" | "v2" | "cf";
/**
* HTTP method used in the event.
*/
method: string;
/**
* The raw path accessed in the event.
*/
rawPath: string;
/**
* The full URL accessed in the event.
*/
url: string;
/**
* The request body as a Buffer.
*/
body: Buffer;
/**
* Headers associated with the event.
*/
headers: Record<string, string>;
/**
* The IP address of the requester.
*/
remoteAddress: string;
/**
* The type of the event.
*/
type: 'v1' | 'v2' | 'cf';
/**
* HTTP method used in the event.
*/
method: string;
/**
* The raw path accessed in the event.
*/
rawPath: string;
/**
* The full URL accessed in the event.
*/
url: string;
/**
* The request body as a Buffer.
*/
body: Buffer;
/**
* Headers associated with the event.
*/
headers: Record<string, string>;
/**
* The IP address of the requester.
*/
remoteAddress: string;
};
/**
* Represents an internal result format.
*/
export type InternalResult = {
/**
* The type of the result.
*/
type: "v1" | "v2" | "cf";
/**
* HTTP status code.
*/
statusCode: number;
/**
* Headers to send in the response.
*/
headers: Record<string, string | string[]>;
/**
* The response body as a string.
*/
body: string;
/**
* Whether the body is base64 encoded.
*/
isBase64Encoded: boolean;
/**
* The type of the result.
*/
type: 'v1' | 'v2' | 'cf';
/**
* HTTP status code.
*/
statusCode: number;
/**
* Headers to send in the response.
*/
headers: Record<string, string | string[]>;
/**
* The response body as a string.
*/
body: string;
/**
* Whether the body is base64 encoded.
*/
isBase64Encoded: boolean;
};
export type APIGatewayProxyEventV2 = import("aws-lambda").APIGatewayProxyEventV2;
export type APIGatewayProxyResultV2 = import("aws-lambda").APIGatewayProxyResultV2;
export type APIGatewayProxyEvent = import("aws-lambda").APIGatewayProxyEvent;
export type APIGatewayProxyResult = import("aws-lambda").APIGatewayProxyResult;
export type CloudFrontRequestEvent = import("aws-lambda").CloudFrontRequestEvent;
export type CloudFrontRequestResult = import("aws-lambda").CloudFrontRequestResult;
export type CloudFrontHeaders = import("aws-lambda").CloudFrontHeaders;
export type APIGatewayProxyEventV2 =
import('aws-lambda').APIGatewayProxyEventV2;
export type APIGatewayProxyResultV2 =
import('aws-lambda').APIGatewayProxyResultV2;
export type APIGatewayProxyEvent = import('aws-lambda').APIGatewayProxyEvent;
export type APIGatewayProxyResult = import('aws-lambda').APIGatewayProxyResult;
export type CloudFrontRequestEvent =
import('aws-lambda').CloudFrontRequestEvent;
export type CloudFrontRequestResult =
import('aws-lambda').CloudFrontRequestResult;
export type CloudFrontHeaders = import('aws-lambda').CloudFrontHeaders;
4 changes: 2 additions & 2 deletions handler/event-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { debug } from './logger.js';

/**
* Represents an internal event type.
* @typedef {Object} InternalEvent
* @typedef {object} InternalEvent
* @property {"v1"|"v2"|"cf"} type The type of the event.
* @property {string} method HTTP method used in the event.
* @property {string} rawPath The raw path accessed in the event.
Expand All @@ -24,7 +24,7 @@ import { debug } from './logger.js';

/**
* Represents an internal result format.
* @typedef {Object} InternalResult
* @typedef {object} InternalResult
* @property {"v1"|"v2"|"cf"} type The type of the result.
* @property {number} statusCode HTTP status code.
* @property {Record<string, string|string[]>} headers Headers to send in the response.
Expand Down
29 changes: 19 additions & 10 deletions handler/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
* @param {APIGatewayProxyEventV2 | CloudFrontRequestEvent | APIGatewayProxyEvent} event - The incoming event from AWS Lambda.
* @returns {Promise<any>} The response to be returned to AWS Lambda.
*/
export function handler(event: import("aws-lambda").APIGatewayProxyEventV2 | CloudFrontRequestEvent | import("aws-lambda").APIGatewayProxyEvent): Promise<any>;
export type InternalEvent = import("./event-mapper.js").InternalEvent;
export type ServerType = import("@sveltejs/kit").Server;
export type APIGatewayProxyEventV2 = import("aws-lambda").APIGatewayProxyEventV2;
export type APIGatewayProxyEvent = import("aws-lambda").APIGatewayProxyEvent;
export type CloudFrontRequestEvent = import("aws-lambda").CloudFrontRequestEvent;
export type CloudFrontRequest = import("aws-lambda").CloudFrontRequest;
export type CloudFrontRequestResult = import("aws-lambda").CloudFrontRequestResult;
export type APIGatewayProxyResultV2 = import("aws-lambda").APIGatewayProxyResultV2;
export type APIGatewayProxyResult = import("aws-lambda").APIGatewayProxyResult;
export function handler(
event:
| import('aws-lambda').APIGatewayProxyEventV2
| CloudFrontRequestEvent
| import('aws-lambda').APIGatewayProxyEvent
): Promise<any>;
export type InternalEvent = import('./event-mapper.js').InternalEvent;
export type ServerType = import('@sveltejs/kit').Server;
export type APIGatewayProxyEventV2 =
import('aws-lambda').APIGatewayProxyEventV2;
export type APIGatewayProxyEvent = import('aws-lambda').APIGatewayProxyEvent;
export type CloudFrontRequestEvent =
import('aws-lambda').CloudFrontRequestEvent;
export type CloudFrontRequest = import('aws-lambda').CloudFrontRequest;
export type CloudFrontRequestResult =
import('aws-lambda').CloudFrontRequestResult;
export type APIGatewayProxyResultV2 =
import('aws-lambda').APIGatewayProxyResultV2;
export type APIGatewayProxyResult = import('aws-lambda').APIGatewayProxyResult;
32 changes: 16 additions & 16 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ export type Builder = import('@sveltejs/kit').Builder;
* Adapter options type definition.
*/
export type AdapterOptions = {
/**
* - The output directory for the adapter
*/
out?: string | undefined;
/**
* - Whether to build for edge deployment (requires environment variables to use placeholders)
*/
edge?: boolean | undefined;
/**
* - Whether to build for response streaming (requires lambda invoke method to be RESPONSE_STREAM)
*/
stream?: boolean | undefined;
/**
* - Additional esbuild options
*/
esbuild?: import("esbuild").BuildOptions | undefined;
/**
* - The output directory for the adapter
*/
out?: string | undefined;
/**
* - Whether to build for edge deployment (requires environment variables to use placeholders)
*/
edge?: boolean | undefined;
/**
* - Whether to build for response streaming (requires lambda invoke method to be RESPONSE_STREAM)
*/
stream?: boolean | undefined;
/**
* - Additional esbuild options
*/
esbuild?: import('esbuild').BuildOptions | undefined;
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fileURLToPath } from 'node:url';

/**
* Adapter options type definition.
* @typedef {Object} AdapterOptions
* @typedef {object} AdapterOptions
* @property {string} [out] - The output directory for the adapter
* @property {boolean} [edge] - Whether to build for edge deployment (requires environment variables to use placeholders)
* @property {boolean} [stream] - Whether to build for response streaming (requires lambda invoke method to be RESPONSE_STREAM)
Expand Down
Loading
Loading