write to a file the connection string

This commit is contained in:
pablof7z 2023-06-27 01:59:39 +02:00
commit f949c116db
9 changed files with 512 additions and 918 deletions

2
.gitignore vendored
View file

@ -4,4 +4,4 @@ dist
**/*.d.ts **/*.d.ts
**/*.d.ts.map **/*.d.ts.map
nsecbunker.json nsecbunker.json
prisma/nsecbunker.db* connection.txt

View file

@ -1,12 +1,15 @@
FROM --platform=linux/amd64 node:slim as build FROM --platform=linux/amd64 node:19 as build
WORKDIR /app WORKDIR /app
COPY package.json . COPY package.json package-lock.json .
RUN npm i RUN npm i
COPY . . COPY src/ src/
COPY prisma/ prisma/
COPY tsconfig.json .
RUN npm run build RUN npm run build
RUN npx prisma generate RUN npx prisma migrate deploy
ENTRYPOINT [ "node", "dist/index.js" ] ENTRYPOINT [ "node", "dist/index.js" ]
CMD ["start"] CMD ["start"]

1421
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "nsecbunkerd", "name": "nsecbunkerd",
"version": "0.6.1", "version": "0.6.2",
"description": "nsecbunker daemon", "description": "nsecbunker daemon",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {
@ -39,10 +39,7 @@
"@prisma/client": "^4.16.1", "@prisma/client": "^4.16.1",
"@scure/base": "^1.1.1", "@scure/base": "^1.1.1",
"@types/yargs": "^17.0.24", "@types/yargs": "^17.0.24",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0", "eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.27.5",
"eventemitter3": "^5.0.1", "eventemitter3": "^5.0.1",

3
pnpm-lock.yaml generated
View file

@ -32,9 +32,6 @@ dependencies:
dotenv: dotenv:
specifier: ^16.3.1 specifier: ^16.3.1
version: 16.3.1 version: 16.3.1
eslint:
specifier: ^8.43.0
version: 8.43.0
eslint-config-prettier: eslint-config-prettier:
specifier: ^8.8.0 specifier: ^8.8.0
version: 8.8.0(eslint@8.43.0) version: 8.8.0(eslint@8.43.0)

BIN
prisma/nsecbunker.db Normal file

Binary file not shown.

View file

@ -8,6 +8,7 @@ import createNewKey from './commands/create_new_key';
import createNewPolicy from './commands/create_new_policy'; import createNewPolicy from './commands/create_new_policy';
import createNewToken from './commands/create_new_token'; import createNewToken from './commands/create_new_token';
import unlockKey from './commands/unlock_key'; import unlockKey from './commands/unlock_key';
import fs from 'fs';
export type IAdminOpts = { export type IAdminOpts = {
npubs: string[]; npubs: string[];
@ -47,6 +48,9 @@ class AdminInterface {
console.log(`\n\nnsecBunker connection string:\n\n${connectionString}\n\n`); console.log(`\n\nnsecBunker connection string:\n\n${connectionString}\n\n`);
// write connection string to connection.txt
fs.writeFileSync('connection.txt', connectionString);
this.signerUser = user; this.signerUser = user;
this.connect(); this.connect();

View file

@ -44,8 +44,6 @@ function getKeys(config: DaemonConfig) {
keys.push(key); keys.push(key);
} }
console.log({ lockedKeyNames });
for (const name of lockedKeyNames) { for (const name of lockedKeyNames) {
keys.push({ name }); keys.push({ name });
} }
@ -213,14 +211,10 @@ class Daemon {
await this.ndk.connect(5000); await this.ndk.connect(5000);
setTimeout(async () => { setTimeout(async () => {
const promise = [];
for (const [name, nsec] of Object.entries(this.config.keys)) { for (const [name, nsec] of Object.entries(this.config.keys)) {
promise.push(this.startKey(name, nsec)); await this.startKey(name, nsec);
} }
// await Promise.all(promise);
console.log('✅ nsecBunker ready to serve requests.'); console.log('✅ nsecBunker ready to serve requests.');
}, 1000); }, 1000);
} }

View file

@ -25,7 +25,7 @@
/* Strict Type-Checking Options */ /* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */, "strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */ // "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */