Skip to content

Commit

Permalink
Make Hello world Lambda more concise (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen authored Feb 1, 2024
1 parent 8779399 commit 8adbb2c
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions typescript/hello-world-lambda/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@

import * as restate from "@restatedev/restate-sdk";

const doGreet = async (ctx: restate.RpcContext, name: string) => {
return `Hello ${name} :-)`;
};

const doGreetAndRemember = async (ctx: restate.RpcContext, name: string) => {
let seen = (await ctx.get<number>("seen")) ?? 0;
seen += 1;

ctx.set("seen", seen);
return `Hello ${name} for the #${seen} time :-)`;
};

const router = restate.keyedRouter({
greet: doGreet,
greetAndRemember: doGreetAndRemember,
greet: async (ctx: restate.RpcContext, name: string) => {
return `Hello ${name} :-)`;
},
greetAndRemember: async (ctx: restate.RpcContext, name: string) => {
let seen = (await ctx.get<number>("seen")) ?? 0;
seen += 1;

ctx.set("seen", seen);
return `Hello ${name} for the #${seen} time :-)`;
},
});

export const handler = restate
Expand Down

0 comments on commit 8adbb2c

Please sign in to comment.