Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
example: update playground
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Oct 18, 2024
1 parent 0d80976 commit 23cde01
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
30 changes: 30 additions & 0 deletions examples/internal/playground/functions/redis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Cluster } from "ioredis";
import { Resource } from "sst";

const client = new Cluster(
[
{
host: Resource.MyRedis.host,
port: Resource.MyRedis.port,
},
],
{
redisOptions: {
tls: {
checkServerIdentity: () => undefined,
},
username: Resource.MyRedis.username,
password: Resource.MyRedis.password,
},
}
);

export async function handler() {
await client.set("foo", `bar-${Date.now()}`);
return {
statusCode: 200,
body: JSON.stringify({
foo: await client.get("foo"),
}),
};
}
3 changes: 2 additions & 1 deletion examples/internal/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "ISC",
"dependencies": {
"@aws-sdk/client-sesv2": "^3.515.0",
"sst": "3.2.31"
"ioredis": "^5.4.1",
"sst": "0.0.0-1729216281"
}
}
12 changes: 12 additions & 0 deletions examples/internal/playground/sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default $config({
//const app = addFunction();
//const service = addService();
//const postgres = addPostgres();
//const redis = addRedis();
//const cron = addCron();

return ret;
Expand Down Expand Up @@ -144,5 +145,16 @@ export default $config({
ret.pgPassword = postgres.password;
return postgres;
}

function addRedis() {
const redis = new sst.aws.Redis("MyRedis", { vpc });
const app = new sst.aws.Function("MyRedisApp", {
handler: "functions/redis/index.handler",
url: true,
vpc,
link: [redis],
});
return redis;
}
},
});

0 comments on commit 23cde01

Please sign in to comment.