Merge pull request #28 from nourspace/nour/feat/improved-configs

feat: improved configs
This commit is contained in:
Pablo Fernandez 2024-01-26 16:17:15 +00:00 committed by GitHub
commit ed9c130ff6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 21 additions and 14 deletions

View file

@ -4,8 +4,8 @@
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
# Enable to use different location for dev db file # Change to use different location for dev db file
# DATABASE_URL="file:./dev.db" DATABASE_URL="file:$HOME/.nsecbunker-config/nsecbunker.db"
# Add your admin Nostr npub # Add your admin Nostr npub
# ADMIN_NPUBS=npub1q2s369... # ADMIN_NPUBS=npub1q2s369...

View file

@ -7,13 +7,15 @@ To quickly install `nsecbunkerd` via Docker just run:
### Configurations ### Configurations
Prepare your config directory - Prepare your config directory
```shell
mkdir $HOME/.nsecbunker-config
```
```shell - Clone `.env.example` and add your nostr public key to `ADMIN_NPUBS` to the `.env` file.
mkdir $HOME/.nsecbunker-config
```
Clone `.env.example` and add your nostr public key to `ADMIN_NPUBS` to the `.env` file. - Change `DATABASE_URL` if necessary.
```shell ```shell
cp .env.example .env cp .env.example .env
@ -38,7 +40,7 @@ docker compose up -d
### Get the connection string ### Get the connection string
```shell ```shell
docker compose exec nsecbunkerd cat /app/connection.txt docker compose exec nsecbunkerd cat /app/config/connection.txt
``` ```
nsecBunker will give you a connection string like: nsecBunker will give you a connection string like:

View file

@ -11,7 +11,7 @@ services:
volumes: volumes:
- $HOME/.nsecbunker-config:/app/config - $HOME/.nsecbunker-config:/app/config
env_file: env_file:
- .env.example - .env
ports: ports:
- "3000:3000" - "3000:3000"
depends_on: depends_on:
@ -22,7 +22,7 @@ services:
volumes: volumes:
- $HOME/.nsecbunker-config:/app/config - $HOME/.nsecbunker-config:/app/config
env_file: env_file:
- .env.example - .env
restart: no restart: no
entrypoint: "" entrypoint: ""
command: command:

View file

@ -1,11 +1,11 @@
generator client { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"] binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"]
} }
datasource db { datasource db {
provider = "sqlite" provider = "sqlite"
url = "file:../config/nsecbunker.db" url = env("DATABASE_URL")
} }
model Request { model Request {

View file

@ -33,6 +33,7 @@ export interface IConfig {
}; };
admin: IAdminOpts; admin: IAdminOpts;
authPort?: number; authPort?: number;
authHost?: string;
database: string; database: string;
logs: string; logs: string;
keys: Record<string, any>; keys: Record<string, any>;
@ -49,6 +50,7 @@ const defaultConfig: IConfig = {
] ]
}, },
authPort: 3000, authPort: 3000,
authHost: 'localhost',
admin: { admin: {
npubs: [], npubs: [],
adminRelays: [ adminRelays: [

View file

@ -17,6 +17,8 @@ import fs from 'fs';
import { validateRequestFromAdmin } from './validations/request-from-admin'; import { validateRequestFromAdmin } from './validations/request-from-admin';
import { dmUser } from '../../utils/dm-user'; import { dmUser } from '../../utils/dm-user';
import { IConfig, getCurrentConfig } from "../../config"; import { IConfig, getCurrentConfig } from "../../config";
import path from 'path';
const debug = createDebug("nsecbunker:admin"); const debug = createDebug("nsecbunker:admin");
@ -63,7 +65,8 @@ 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 // write connection string to connection.txt
fs.writeFileSync('connection.txt', connectionString); const configFolder = path.dirname(configFile)
fs.writeFileSync(path.join(configFolder, 'connection.txt'), connectionString);
this.signerUser = user; this.signerUser = user;

View file

@ -185,7 +185,7 @@ class Daemon {
} }
}); });
this.fastify.listen({ port: this.config.authPort }); this.fastify.listen({ port: this.config.authPort, host: this.config.authHost });
this.fastify.get('/requests/:id', authorizeRequestWebHandler); this.fastify.get('/requests/:id', authorizeRequestWebHandler);
this.fastify.post('/requests/:id', processRequestWebHandler); this.fastify.post('/requests/:id', processRequestWebHandler);