Skip to content

Commit c62c442

Browse files
Merge branch 'main' of https://github.com/cameri/nostream into fix/opennode-webhook-validation
# Conflicts: # src/controllers/callbacks/opennode-callback-controller.ts
2 parents a8d26a6 + db8b4d4 commit c62c442

70 files changed

Lines changed: 8001 additions & 3970 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONFIGURATION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ Running `nostream` for the first time creates the settings file in `<project_roo
109109
| limits.event.rateLimits[].rate | Maximum number of events during period. |
110110
| limits.event.whitelists.pubkeys | List of public keys to ignore rate limits. |
111111
| limits.event.whitelists.ipAddresses | List of IPs (IPv4 or IPv6) to ignore rate limits. |
112+
| limits.event.retention.maxDays | Maximum number of days to retain events. Purge deletes events that are expired (`expires_at`), soft-deleted (`deleted_at`), or older than this window (`created_at`). Any non-positive value disables retention purge. |
113+
| limits.event.retention.kind.whitelist | Event kinds excluded from retention purge. NIP-62 `REQUEST_TO_VANISH` is always excluded from retention purge, even if not listed here. |
114+
| limits.event.retention.pubkey.whitelist | Public keys excluded from retention purge. |
112115
| limits.client.subscription.maxSubscriptions | Maximum number of subscriptions per connected client. Defaults to 10. Disabled when set to zero. |
113116
| limits.client.subscription.maxFilters | Maximum number of filters per subscription. Defaults to 10. Disabled when set to zero. |
114117
| limits.message.rateLimits[].period | Rate limit period in milliseconds. |

Dockerfile.railwayapp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ ADD migrations /build/migrations
2323

2424
RUN npm install -g knex@2.4.0 && npm install --quiet
2525

26-
RUN npm run db:migrate
27-
2826
COPY . .
2927

3028
RUN npm run build
3129

3230
FROM node:24-alpine
3331

32+
# Install dumb-init for proper signal handling
33+
RUN apk add --no-cache dumb-init
34+
3435
ARG PORT
3536
ARG PGHOST
3637
ARG PGPORT
@@ -71,12 +72,19 @@ LABEL org.opencontainers.image.licenses=MIT
7172

7273
WORKDIR /app
7374

75+
# Copy runtime artifacts and configuration
7476
COPY --from=build /build/dist .
77+
COPY --from=build /build/package.json /build/package-lock.json ./
78+
COPY --from=build /build/knexfile.js ./
79+
COPY --from=build /build/migrations ./migrations
80+
COPY --from=build /build/seeds ./seeds
7581

76-
RUN npm install --omit=dev --quiet
82+
RUN npm install --omit=dev --quiet && npm install -g knex@2.4.0
7783

7884
USER 1000:1000
7985

8086
RUN mkdir -p $NOSTR_CONFIG_DIR
8187

82-
CMD ["node", "src/index.js"]
88+
ENTRYPOINT ["dumb-init", "--"]
89+
90+
CMD ["sh", "-c", "npm run db:migrate && node src/index.js"]

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,44 @@ To see the integration test coverage report open `.coverage/integration/lcov-rep
570570
open .coverage/integration/lcov-report/index.html
571571
```
572572
573+
## Relay Maintenance
574+
575+
Use `clean-db` to wipe or prune `events` table data. This also removes
576+
corresponding data from the derived `event_tags` table when present.
577+
578+
Dry run (no deletion):
579+
580+
```
581+
npm run clean-db -- --all --dry-run
582+
```
583+
584+
Full wipe:
585+
586+
```
587+
npm run clean-db -- --all --force
588+
```
589+
590+
Delete events older than N days:
591+
592+
```
593+
npm run clean-db -- --older-than=30 --force
594+
```
595+
596+
Delete only selected kinds:
597+
598+
```
599+
npm run clean-db -- --kinds=1,7,4 --force
600+
```
601+
602+
Delete only selected kinds older than N days:
603+
604+
```
605+
npm run clean-db -- --older-than=30 --kinds=1,7,4 --force
606+
```
607+
608+
By default, the script asks for explicit confirmation (`Type 'DELETE' to confirm`).
609+
Use `--force` to skip the prompt.
610+
573611
## Configuration
574612
575613
You can change the default folder by setting the `NOSTR_CONFIG_DIR` environment variable to a different path.

commitlint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module.exports = {
22
extends: ['@commitlint/config-conventional'],
33
parserPreset: 'conventional-changelog-conventionalcommits',
44
rules: {
5-
'body-max-line-length': [2, 'always', 250],
5+
'body-max-line-length': [0, 'always'],
6+
'header-max-length': [0, 'always'],
67
'subject-case': [0, 'always'],
78
'header-case': [0, 'always'],
89
'body-case': [0, 'always'],

cucumber.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const config = [
1111
'--format @cucumber/pretty-formatter',
1212
'--format html:.test-reports/integration/report.html',
1313
'--format json:.test-reports/integration/report.json',
14-
'--publish',
1514
].join(' ')
1615

1716
module.exports = {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
exports.up = async function (knex) {
2+
return knex.schema
3+
.raw(
4+
`CREATE OR REPLACE FUNCTION admit_user(user_pubkey BYTEA, tos_accepted TIMESTAMP WITHOUT TIME ZONE)
5+
RETURNS INTEGER
6+
LANGUAGE plpgsql
7+
AS $$
8+
BEGIN
9+
PERFORM ASSERT_SERIALIZED();
10+
11+
INSERT INTO "users" ("pubkey", "is_admitted", "tos_accepted_at", "created_at", "updated_at")
12+
VALUES (user_pubkey, true, tos_accepted, now_utc(), now_utc())
13+
ON CONFLICT ("pubkey")
14+
DO UPDATE SET
15+
"is_admitted" = true,
16+
"tos_accepted_at" = tos_accepted,
17+
"updated_at" = now_utc();
18+
19+
RETURN 0;
20+
END;
21+
$$;`)
22+
}
23+
24+
exports.down = function (knex) {
25+
return knex.schema
26+
.raw('DROP FUNCTION IF EXISTS admit_user(BYTEA, TIMESTAMP WITHOUT TIME ZONE);')
27+
}

0 commit comments

Comments
 (0)