Skip to content

Commit

Permalink
fix(types): added readme and removed external type reliance
Browse files Browse the repository at this point in the history
  • Loading branch information
John Conley committed Dec 6, 2018
1 parent b3fd23c commit c81c9af
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# valory-adaptor-alb
Valory adaptor that processes request forwarded from an AWS Application Load Balancer.
Very small and lightweight, only requires being run in a lambda with the proper permissions.
3 changes: 1 addition & 2 deletions src/albAdaptor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import FMW = require("find-my-way");
import {Callback, Context} from "aws-lambda";
import {ApiRequest, ApiResponse, ApiServer, HttpMethod, ValoryMetadata} from "valory-runtime";
import {ALBRequestEvent, ALBResponse, FormattedRequest} from "./types/alb";
import {ALBRequestEvent, ALBResponse, Callback, Context, FormattedRequest} from "./types/alb";
import qs = require("querystring");

const pathReplacer = /{([\S]*?)}/g;
Expand Down
57 changes: 54 additions & 3 deletions src/types/alb.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {Context} from "aws-lambda";

export interface ALBRequestEvent {
requestContext: {
elb: {
Expand Down Expand Up @@ -35,4 +33,57 @@ export interface ALBResponse {
isBase64Encoded: boolean;
headers?: {[key: string]: string};
body?: string;
}
}

export interface Context {
// Properties
callbackWaitsForEmptyEventLoop: boolean;
functionName: string;
functionVersion: string;
invokedFunctionArn: string;
memoryLimitInMB: number;
awsRequestId: string;
logGroupName: string;
logStreamName: string;
identity?: CognitoIdentity;
clientContext?: ClientContext;

// Functions
getRemainingTimeInMillis(): number;

// Functions for compatibility with earlier Node.js Runtime v0.10.42
// For more details see http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-using-old-runtime.html#nodejs-prog-model-oldruntime-context-methods
done(error?: Error, result?: any): void;
fail(error: Error | string): void;
succeed(messageOrObject: any): void;
succeed(message: string, object: any): void;
}

export interface CognitoIdentity {
cognitoIdentityId: string;
cognitoIdentityPoolId: string;
}

export interface ClientContext {
client: ClientContextClient;
custom?: any;
env: ClientContextEnv;
}

export interface ClientContextClient {
installationId: string;
appTitle: string;
appVersionName: string;
appVersionCode: string;
appPackageName: string;
}

export interface ClientContextEnv {
platformVersion: string;
platform: string;
make: string;
model: string;
locale: string;
}

export type Callback<TResult = any> = (error?: Error | null | string, result?: TResult) => void;

0 comments on commit c81c9af

Please sign in to comment.