@stamprally/server 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -18
- package/dist/index.cjs +366 -629
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -135
- package/dist/index.d.ts +79 -135
- package/dist/index.js +368 -629
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
# @stamprally/server
|
|
2
2
|
|
|
3
|
-
Web Standard `Request` / `Response` handlers for server-authoritative
|
|
4
|
-
check-ins, reward claims, and offline synchronization.
|
|
3
|
+
Web Standard `Request` / `Response` handlers for server-authoritative check-ins and reward claims.
|
|
5
4
|
|
|
6
5
|
```ts
|
|
7
6
|
import { StampRallyServer } from "@stamprally/server";
|
|
8
7
|
|
|
9
|
-
const server = new StampRallyServer(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
secretKey: process.env.RALLY_SECRET ?? "replace-me",
|
|
13
|
-
stamps: [{ id: "gate", name: { en: "Gate" }, condition: { type: "instant" } }],
|
|
14
|
-
},
|
|
15
|
-
storage,
|
|
16
|
-
);
|
|
17
|
-
|
|
8
|
+
const server = new StampRallyServer(adminConfig, persistence, {
|
|
9
|
+
authenticate: (request) => request.headers.get("x-user-id"),
|
|
10
|
+
});
|
|
18
11
|
const response = await server.handle(request);
|
|
19
12
|
```
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
`ServerPersistenceAdapter` scopes locks, reward stock, idempotency records, user state, claim records, and audit logs by `rallyId`. Its `recordUserClaim` operation receives the rally, user, reward, issued ticket number, and timestamp. Use a transactional database or equivalent Redis primitives for multi-instance production deployments.
|
|
15
|
+
|
|
16
|
+
Hono can mount the handler directly because it accepts the same Web Standard request and response types.
|
|
17
|
+
|
|
18
|
+
## License
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
`authenticate` to return the authenticated user ID. The handler rejects bodies
|
|
28
|
-
that attempt to act for a different user.
|
|
20
|
+
MIT
|