Skip to content

Instantly share code, notes, and snippets.

@kukielp
Created June 1, 2020 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kukielp/a7be92041c70b316cd9ec8fcf3402db8 to your computer and use it in GitHub Desktop.
Save kukielp/a7be92041c70b316cd9ec8fcf3402db8 to your computer and use it in GitHub Desktop.
import {
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context
} from "https://deno.land/x/lambda/mod.ts";
export async function handler(
event: APIGatewayProxyEvent,
context: Context
): Promise<APIGatewayProxyResult> {
return {
statusCode: 200,
headers: { "Content-Type": "text/json" },
body: JSON.stringify(constructResponse(event)),
};
}
class Person {
private _fullName: string;
get fullName(): string {
return this._fullName + '!';
}
constructor(firstName: string, ) {
this._fullName = firstName;
}
}
class Result {
user: Person;
message: string;
constructor(u: Person, m: string){
this.message = m;
this.user = u;
}
}
const constructResponse = (event: APIGatewayProxyEvent) => {
let name = event.path.replace("/","");
let p = new Person(name);
let r = new Result(p, `Hi ${p.fullName}, Welcome to deno ${Deno.version.deno} 🦕`);
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment