Skip to content

Commit 2c5b6b3

Browse files
committed
added Quickstart
1 parent c632af8 commit 2c5b6b3

6 files changed

Lines changed: 85 additions & 35 deletions

File tree

README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,7 @@ TypeScript server SDK for age verification, designed to help websites implement
1919
pnpm add @agecheck/node
2020
```
2121

22-
## Runtime requirement
23-
24-
- Node.js `>=20`
25-
26-
## Required environment variables
27-
28-
```bash
29-
AGECHECK_COOKIE_SECRET=replace_with_32_plus_bytes_random
30-
AGECHECK_DEPLOYMENT_MODE=production
31-
AGECHECK_REQUIRED_AGE=18
32-
AGECHECK_GATE_HEADER_NAME=X-Age-Gate
33-
AGECHECK_GATE_HEADER_REQUIRED_VALUE=true
34-
```
22+
Quickstart: see `/docs/QUICKSTART.md`.
3523

3624
## Supported integration modes
3725

docs/QUICKSTART.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Quickstart
2+
3+
Use this page for shared runtime and configuration requirements across all Node framework adapters.
4+
5+
## Runtime
6+
7+
- Node.js `>=20`
8+
9+
## Required environment variables
10+
11+
```bash
12+
AGECHECK_COOKIE_SECRET=replace_with_32_plus_bytes_random
13+
AGECHECK_DEPLOYMENT_MODE=production
14+
AGECHECK_REQUIRED_AGE=18
15+
AGECHECK_GATE_HEADER_NAME=X-Age-Gate
16+
AGECHECK_GATE_HEADER_REQUIRED_VALUE=true
17+
```
18+
19+
Notes:
20+
- `AGECHECK_COOKIE_SECRET` must be at least 32 bytes.
21+
- `AGECHECK_DEPLOYMENT_MODE`:
22+
- `production`: accepts production issuer credentials and raises gate only when header policy requires it
23+
- `demo`: accepts demo + production issuer credentials and always raises gate
24+
25+
## Recommended pattern
26+
27+
Use framework adapter handlers for verify and gate enforcement:
28+
29+
- Express: `createExpressVerifyHandler`, `createExpressGateMiddleware`
30+
- Fastify: `createFastifyVerifyHandler`, `createFastifyGateHook`
31+
- Hono: `createHonoVerifyHandler`, `createHonoGateMiddleware`
32+
- Nuxt: `createNuxtVerifyHandler`, `createNuxtGateMiddleware`
33+
34+
Most hostmasters should not manually call low-level cookie helpers.
35+
36+
## Troubleshooting
37+
38+
If verify response shows:
39+
40+
```json
41+
{
42+
"verified": false,
43+
"code": "verify_failed",
44+
"error": "Failed to issue verification cookie"
45+
}
46+
```
47+
48+
check:
49+
- Node runtime is `>=20`
50+
- `AGECHECK_COOKIE_SECRET` is present in the running process and is at least 32 bytes
51+
- request contains `payload.agegateway_session` as a UUID
52+
- you are using adapter handlers instead of manual cookie issuance paths

docs/frameworks/express.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Express Integration
22

3+
Prerequisites: see `/docs/QUICKSTART.md`.
4+
35
```ts
46
import express from "express";
57
import {
@@ -28,13 +30,3 @@ app.get("/restricted", (_req, res) => {
2830
res.status(200).send("Restricted content");
2931
});
3032
```
31-
32-
Required environment variables:
33-
34-
```bash
35-
AGECHECK_COOKIE_SECRET=replace_with_32_plus_bytes_random
36-
AGECHECK_DEPLOYMENT_MODE=production
37-
AGECHECK_REQUIRED_AGE=18
38-
AGECHECK_GATE_HEADER_NAME=X-Age-Gate
39-
AGECHECK_GATE_HEADER_REQUIRED_VALUE=true
40-
```

docs/frameworks/fastify.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Fastify Integration
22

3+
Prerequisites: see `/docs/QUICKSTART.md`.
4+
35
```ts
46
import Fastify from "fastify";
57
import {
@@ -11,9 +13,12 @@ import {
1113
const fastify = Fastify();
1214

1315
const sdk = new AgeCheckSdk({
14-
deploymentMode: "production",
15-
verify: { requiredAge: 18 },
16-
gate: { headerName: "X-Age-Gate", requiredValue: "true" },
16+
deploymentMode: process.env.AGECHECK_DEPLOYMENT_MODE === "demo" ? "demo" : "production",
17+
verify: { requiredAge: Number(process.env.AGECHECK_REQUIRED_AGE ?? "18") },
18+
gate: {
19+
headerName: process.env.AGECHECK_GATE_HEADER_NAME ?? "X-Age-Gate",
20+
requiredValue: process.env.AGECHECK_GATE_HEADER_REQUIRED_VALUE ?? "true",
21+
},
1722
cookie: { secret: process.env.AGECHECK_COOKIE_SECRET!, cookieName: "agecheck_verified", ttlSeconds: 86400 },
1823
});
1924

docs/frameworks/hono.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Hono Integration
22

3+
Prerequisites: see `/docs/QUICKSTART.md`.
4+
35
```ts
46
import { Hono } from "hono";
57
import {
@@ -11,9 +13,12 @@ import {
1113
const app = new Hono();
1214

1315
const sdk = new AgeCheckSdk({
14-
deploymentMode: "production",
15-
verify: { requiredAge: 18 },
16-
gate: { headerName: "X-Age-Gate", requiredValue: "true" },
16+
deploymentMode: process.env.AGECHECK_DEPLOYMENT_MODE === "demo" ? "demo" : "production",
17+
verify: { requiredAge: Number(process.env.AGECHECK_REQUIRED_AGE ?? "18") },
18+
gate: {
19+
headerName: process.env.AGECHECK_GATE_HEADER_NAME ?? "X-Age-Gate",
20+
requiredValue: process.env.AGECHECK_GATE_HEADER_REQUIRED_VALUE ?? "true",
21+
},
1722
cookie: { secret: process.env.AGECHECK_COOKIE_SECRET!, cookieName: "agecheck_verified", ttlSeconds: 86400 },
1823
});
1924

docs/frameworks/nuxt.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Nuxt Server Integration
22

3+
Prerequisites: see `/docs/QUICKSTART.md`.
4+
35
```ts
46
// server/middleware/agecheck.ts
57
import {
@@ -8,9 +10,12 @@ import {
810
} from "@agecheck/node";
911

1012
const sdk = new AgeCheckSdk({
11-
deploymentMode: "production",
12-
verify: { requiredAge: 18 },
13-
gate: { headerName: "X-Age-Gate", requiredValue: "true" },
13+
deploymentMode: process.env.AGECHECK_DEPLOYMENT_MODE === "demo" ? "demo" : "production",
14+
verify: { requiredAge: Number(process.env.AGECHECK_REQUIRED_AGE ?? "18") },
15+
gate: {
16+
headerName: process.env.AGECHECK_GATE_HEADER_NAME ?? "X-Age-Gate",
17+
requiredValue: process.env.AGECHECK_GATE_HEADER_REQUIRED_VALUE ?? "true",
18+
},
1419
cookie: { secret: process.env.AGECHECK_COOKIE_SECRET!, cookieName: "agecheck_verified", ttlSeconds: 86400 },
1520
});
1621

@@ -31,9 +36,12 @@ import {
3136
} from "@agecheck/node";
3237

3338
const sdk = new AgeCheckSdk({
34-
deploymentMode: "production",
35-
verify: { requiredAge: 18 },
36-
gate: { headerName: "X-Age-Gate", requiredValue: "true" },
39+
deploymentMode: process.env.AGECHECK_DEPLOYMENT_MODE === "demo" ? "demo" : "production",
40+
verify: { requiredAge: Number(process.env.AGECHECK_REQUIRED_AGE ?? "18") },
41+
gate: {
42+
headerName: process.env.AGECHECK_GATE_HEADER_NAME ?? "X-Age-Gate",
43+
requiredValue: process.env.AGECHECK_GATE_HEADER_REQUIRED_VALUE ?? "true",
44+
},
3745
cookie: { secret: process.env.AGECHECK_COOKIE_SECRET!, cookieName: "agecheck_verified", ttlSeconds: 86400 },
3846
});
3947

0 commit comments

Comments
 (0)