Skip to content

Commit f330243

Browse files
init doorman clone
1 parent 9b5de22 commit f330243

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

apps/doorman-clone/index.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { FetchHttpClient, HttpClient } from "@effect/platform";
2+
import { NodeRuntime } from "@effect/platform-node";
3+
import { NimblebitAuth, NimblebitConfig } from "@tinyburg/nimblebit-sdk";
4+
import { SyncItemType, TinyTower } from "@tinyburg/tinytower-sdk";
5+
import { Config, Effect, Layer, Redacted } from "effect";
6+
7+
const Live = Layer.merge(
8+
FetchHttpClient.layer,
9+
NimblebitAuth.layerNodeTinyburgAuthProxyConfig({
10+
authKey: Config.redacted("AUTH_KEY"),
11+
})
12+
);
13+
14+
const program = Effect.gen(function* () {
15+
const authenticatedPlayer = yield* NimblebitConfig.AuthenticatedPlayerConfig;
16+
const { visits } = yield* TinyTower.social_getVisits(authenticatedPlayer);
17+
18+
for (const visit of visits) {
19+
console.log(visit);
20+
continue;
21+
22+
yield* TinyTower.social_sendItem({
23+
...authenticatedPlayer,
24+
friendId: visit.from,
25+
itemType: SyncItemType.SyncItemType.Play,
26+
itemStr: `bit:${visit.contents}`,
27+
});
28+
29+
yield* TinyTower.social_receiveGift({
30+
...authenticatedPlayer,
31+
giftId: visit.id,
32+
});
33+
}
34+
35+
// Heartbeat for monitoring
36+
const heartbeatUrl = yield* Config.redacted("HEARTBEAT_URL");
37+
yield* HttpClient.get(Redacted.value(heartbeatUrl));
38+
});
39+
40+
program.pipe(Effect.provide(Live), NodeRuntime.runMain);

apps/doorman-clone/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@tinyburg/doorman-clone",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "node --experimental-strip-types"
8+
},
9+
"dependencies": {
10+
"@effect/cluster": "0.56.1",
11+
"@effect/experimental": "0.58.0",
12+
"@effect/platform": "0.94.1",
13+
"@effect/platform-node": "0.104.0",
14+
"@effect/rpc": "0.73.0",
15+
"@effect/sql": "0.49.0",
16+
"@effect/workflow": "0.16.0",
17+
"@tinyburg/nimblebit-sdk": "workspace:*",
18+
"@tinyburg/tinytower-sdk": "workspace:*",
19+
"effect": "3.19.14"
20+
}
21+
}

pnpm-lock.yaml

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)