mirror of
https://github.com/kind-0/nsecbunkerd.git
synced 2026-08-01 07:21:42 +00:00
fix: load env variables
This commit is contained in:
parent
419eb0318e
commit
f48635de8d
120
src/index.ts
120
src/index.ts
@ -1,68 +1,86 @@
|
||||
#!/usr/bin/env node
|
||||
import 'websocket-polyfill';
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import "websocket-polyfill";
|
||||
import yargs from "yargs";
|
||||
import { hideBin } from "yargs/helpers";
|
||||
import * as dotenv from "dotenv";
|
||||
dotenv.config(); // Load the environment variables
|
||||
|
||||
import { setup } from './commands/setup.js';
|
||||
import { addNsec } from './commands/add.js';
|
||||
import { start } from './commands/start.js';
|
||||
import { setup } from "./commands/setup.js";
|
||||
import { addNsec } from "./commands/add.js";
|
||||
import { start } from "./commands/start.js";
|
||||
|
||||
const adminNpubs = process.env.ADMIN_NPUBS ? process.env.ADMIN_NPUBS.split(',') : [];
|
||||
const adminNpubs = process.env.ADMIN_NPUBS
|
||||
? process.env.ADMIN_NPUBS.split(",")
|
||||
: [];
|
||||
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.command('setup', 'Setup nsecBunker', {}, (argv) => {
|
||||
.command("setup", "Setup nsecBunker", {}, (argv) => {
|
||||
setup(argv.config as string);
|
||||
})
|
||||
|
||||
.command('start', 'Start nsecBunker', (yargs) => {
|
||||
yargs
|
||||
.option('verbose', {
|
||||
alias: 'v',
|
||||
type: 'boolean',
|
||||
description: 'Run with verbose logging',
|
||||
default: false,
|
||||
})
|
||||
.array('key')
|
||||
.option('key <name>', {
|
||||
type: 'string',
|
||||
description: 'Name of key to enable',
|
||||
})
|
||||
.array('admin')
|
||||
.option('admin <npub>', {
|
||||
alias: 'a',
|
||||
type: 'string',
|
||||
description: 'Admin npub',
|
||||
.command(
|
||||
"start",
|
||||
"Start nsecBunker",
|
||||
(yargs) => {
|
||||
yargs
|
||||
.option("verbose", {
|
||||
alias: "v",
|
||||
type: "boolean",
|
||||
description: "Run with verbose logging",
|
||||
default: false,
|
||||
})
|
||||
.array("key")
|
||||
.option("key <name>", {
|
||||
type: "string",
|
||||
description: "Name of key to enable",
|
||||
})
|
||||
.array("admin")
|
||||
.option("admin <npub>", {
|
||||
alias: "a",
|
||||
type: "string",
|
||||
description: "Admin npub",
|
||||
});
|
||||
},
|
||||
(argv) => {
|
||||
start({
|
||||
keys: argv.key as string[],
|
||||
verbose: argv.verbose as boolean,
|
||||
config: argv.config as string,
|
||||
adminNpubs: [
|
||||
...new Set([
|
||||
...((argv.admin || []) as string[]),
|
||||
...adminNpubs,
|
||||
]),
|
||||
],
|
||||
});
|
||||
}, (argv) => {
|
||||
start({
|
||||
keys: argv.key as string[],
|
||||
verbose: argv.verbose as boolean,
|
||||
config: argv.config as string,
|
||||
adminNpubs: [...new Set([...((argv.admin||[]) as string[]), ...adminNpubs])]
|
||||
});
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
.command('add', 'Add an nsec', (yargs) => {
|
||||
yargs
|
||||
.option('name', {
|
||||
alias: 'n',
|
||||
type: 'string',
|
||||
description: 'Name of the nsec',
|
||||
.command(
|
||||
"add",
|
||||
"Add an nsec",
|
||||
(yargs) => {
|
||||
yargs.option("name", {
|
||||
alias: "n",
|
||||
type: "string",
|
||||
description: "Name of the nsec",
|
||||
demandOption: true,
|
||||
});
|
||||
}, (argv) => {
|
||||
addNsec({
|
||||
config: argv.config as string,
|
||||
name: argv.name as string
|
||||
});
|
||||
})
|
||||
},
|
||||
(argv) => {
|
||||
addNsec({
|
||||
config: argv.config as string,
|
||||
name: argv.name as string,
|
||||
});
|
||||
}
|
||||
)
|
||||
|
||||
.options({
|
||||
'config': {
|
||||
alias: 'c',
|
||||
type: 'string',
|
||||
description: 'Path to config file',
|
||||
default: 'config/nsecbunker.json',
|
||||
config: {
|
||||
alias: "c",
|
||||
type: "string",
|
||||
description: "Path to config file",
|
||||
default: "config/nsecbunker.json",
|
||||
},
|
||||
})
|
||||
.demandCommand(0, 1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user