Skip to content

Commit d277bc7

Browse files
feat(start): forward Nostr relay flags to JSS (--nostr, --nostr-path, --nostr-max-events) (#67)
Every jspod can now run JSS's in-process NIP-01 relay at <pod>/relay. Off by default; opt in with --nostr. Banner + --help updated. Bump javascript-solid-server to ^0.0.204; v0.0.46. Refs #66
1 parent 557f384 commit d277bc7

3 files changed

Lines changed: 36 additions & 5 deletions

File tree

index.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ const options = {
300300
git: true,
301301
browser: 'folder',
302302
provisionKeys: false,
303-
bootstrap: true
303+
bootstrap: true,
304+
nostr: false,
305+
nostrPath: '/relay'
304306
};
305307

306308
const RUNG_1_USERNAME = 'me';
@@ -362,6 +364,21 @@ for (let i = 0; i < args.length; i++) {
362364
options.mcp = false;
363365
} else if (arg === '--no-bootstrap') {
364366
options.bootstrap = false;
367+
} else if (arg === '--nostr') {
368+
options.nostr = true;
369+
} else if (arg === '--no-nostr') {
370+
options.nostr = false;
371+
} else if (arg === '--nostr-path') {
372+
options.nostrPath = requireValue(arg, args[++i]);
373+
} else if (arg === '--nostr-max-events') {
374+
const raw = requireValue(arg, args[++i]);
375+
const parsed = parseInt(raw, 10);
376+
if (!Number.isInteger(parsed) || parsed < 1 || String(parsed) !== raw.trim()) {
377+
console.error(chalk.red(`✗ Invalid --nostr-max-events: ${raw}`));
378+
console.error(chalk.dim('Must be a positive integer.'));
379+
process.exit(1);
380+
}
381+
options.nostrMaxEvents = parsed;
365382
} else if (arg === '--browser') {
366383
const raw = requireValue(arg, args[++i]);
367384
if (raw !== 'json' && raw !== 'folder') {
@@ -394,6 +411,9 @@ for (let i = 0; i < args.length; i++) {
394411
console.log(chalk.green(' --browser ') + chalk.yellow('<folder|json>') + chalk.dim(' Data browser style (default: folder)'));
395412
console.log(chalk.green(' --provision-keys') + chalk.dim(' Generate a Nostr-compatible owner keypair on first start'));
396413
console.log(chalk.green(' --mcp') + chalk.dim(' Expose /mcp (Model Context Protocol) tool surface for agents'));
414+
console.log(chalk.green(' --nostr') + chalk.dim(' Run a Nostr relay (NIP-01) at <pod>/relay'));
415+
console.log(chalk.green(' --nostr-path ') + chalk.yellow('<path>') + chalk.dim(' Relay WebSocket path (default: /relay)'));
416+
console.log(chalk.green(' --nostr-max-events ') + chalk.yellow('<n>') + chalk.dim(' Max events kept in relay memory (default: 1000)'));
397417
console.log(chalk.green(' --no-bootstrap') + chalk.dim(' Skip auto-install of the `default` app bundle on first run'));
398418
console.log(chalk.green(' -v, --version') + chalk.dim(' Show jspod version'));
399419
console.log(chalk.green(' --help') + chalk.dim(' Show this help message\n'));
@@ -406,6 +426,7 @@ for (let i = 0; i < args.length; i++) {
406426
console.log(chalk.dim(' • WebID authentication'));
407427
console.log(chalk.dim(' • Passkey support'));
408428
console.log(chalk.dim(' • WebSocket notifications'));
429+
console.log(chalk.dim(' • Nostr relay (NIP-01, opt-in via --nostr)'));
409430
console.log(chalk.dim(' • JSON-LD native\n'));
410431
console.log(chalk.white('Resources:'));
411432
console.log(chalk.blue(' https://github.com/JavaScriptSolidServer/jspod'));
@@ -442,7 +463,10 @@ console.log(chalk.cyan(' ├─ ') + chalk.white('URL: ') + chalk.bold.g
442463
console.log(chalk.cyan(' ├─ ') + chalk.white('Port: ') + chalk.yellow(options.port));
443464
console.log(chalk.cyan(' ├─ ') + chalk.white('Host: ') + chalk.yellow(options.host));
444465
console.log(chalk.cyan(' ├─ ') + chalk.white('Pod Root: ') + chalk.yellow(options.root));
445-
console.log(chalk.cyan(' └─ ') + chalk.white('Mode: ') + (options.multiuser ? chalk.yellow('Multi-user') : chalk.yellow('Single-user')));
466+
console.log(chalk.cyan(options.nostr ? ' ├─ ' : ' └─ ') + chalk.white('Mode: ') + (options.multiuser ? chalk.yellow('Multi-user') : chalk.yellow('Single-user')));
467+
if (options.nostr) {
468+
console.log(chalk.cyan(' └─ ') + chalk.white('Relay: ') + chalk.bold.green(`enabled (${options.nostrPath})`));
469+
}
446470

447471
if (options.auth && !options.multiuser) {
448472
const rungLabel = RUNG_1_PASSWORD_FROM_ENV

lib/start.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ const DEFAULTS = {
178178
browser: 'folder',
179179
provisionKeys: false,
180180
mcp: false,
181-
bootstrap: true
181+
bootstrap: true,
182+
nostr: false,
183+
nostrPath: '/relay'
182184
};
183185

184186
/**
@@ -259,6 +261,11 @@ export async function start(userOptions = {}) {
259261
jssArgs.push(options.git ? '--git' : '--no-git');
260262
if (options.provisionKeys) jssArgs.push('--provision-keys');
261263
if (options.mcp) jssArgs.push('--mcp');
264+
if (options.nostr) {
265+
jssArgs.push('--nostr');
266+
if (options.nostrPath) jssArgs.push('--nostr-path', options.nostrPath);
267+
if (options.nostrMaxEvents) jssArgs.push('--nostr-max-events', String(options.nostrMaxEvents));
268+
}
262269

263270
const jss = spawn('jss', jssArgs, {
264271
stdio: 'inherit',

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspod",
3-
"version": "0.0.45",
3+
"version": "0.0.46",
44
"description": "JavaScript Solid Pod - Just works, batteries included",
55
"type": "module",
66
"main": "./lib/index.js",
@@ -57,6 +57,6 @@
5757
},
5858
"dependencies": {
5959
"chalk": "^5.6.2",
60-
"javascript-solid-server": "^0.0.203"
60+
"javascript-solid-server": "^0.0.204"
6161
}
6262
}

0 commit comments

Comments
 (0)