diff --git a/.env.example b/.env.example index 3ed1f11..cafd880 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,6 @@ PORT=7331 SELF_HOSTED_MODE=false +DISABLE_SIGNUP=false UPLOAD_PATH="./data/uploads" DATABASE_URL="postgresql://user@localhost:5432/taxhacker" BETTER_AUTH_SECRET="random-secret-key" diff --git a/README.md b/README.md index efac339..1c87982 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,6 @@ Built-in system of filters, support for multiple projects, import-export of tran ![Dashboard](docs/screenshots/title.png) -> \[!NOTE] -> -> TaxHacker is a single-user app. SaaS or Electron version will probably be developed in the future if anyone is interested. - > \[!IMPORTANT] > > This project is still at a very early stage. Use it at your own risk! **Star Us** to receive notifications about new bugfixes and features from GitHub ⭐️ @@ -151,12 +147,12 @@ Configure TaxHacker to suit your needs with these environment variables: | Variable | Required | Description | Example | |----------|----------|-------------|---------| | `PORT` | No | Port to run the server on | `7331` | -| `SELF_HOSTED_MODE` | No | Enable self-hosted mode and automatic login | `false` | | `UPLOAD_PATH` | Yes | Local directory for uploading files | `./data/uploads` | -| `DATABASE_URL` | Yes | PostgreSQL connection string | `postgresql://postgres:postgres@localhost:5432/taxhacker` | -| `OPENAI_API_KEY` | No | OpenAI API key for AI features | `sk-...` | +| `DATABASE_URL` | Yes | PostgreSQL connection string | `postgresql://user@localhost:5432/taxhacker` | +| `SELF_HOSTED_MODE` | No | Set it to "true" if you're self-hosting the app: it enables auto-login, custom API keys, and more | `false` | +| `DISABLE_SIGNUP` | No | Disable new user registration on your instance | `false` | +| `OPENAI_API_KEY` | No | OpenAI API key for AI features. In self-hosted mode you can set it up in settings too. | `sk-...` | | `RESEND_API_KEY` | No | Resend API key for email notifications | `re_...` | -| `RESEND_AUDIENCE_ID` | No | Resend audience ID for newsletters | `fde8dd49-...` | | `RESEND_FROM_EMAIL` | No | Email address to send from | `TaxHacker ` | diff --git a/app/(app)/settings/backups/actions.ts b/app/(app)/settings/backups/actions.ts index 398a487..83e155d 100644 --- a/app/(app)/settings/backups/actions.ts +++ b/app/(app)/settings/backups/actions.ts @@ -30,11 +30,6 @@ export async function restoreBackupAction(prevState: any, formData: FormData) { return { success: false, error: "Bad zip archive" } } - if (REMOVE_EXISTING_DATA) { - await cleanupUserTables(user.id) - await fs.rm(userUploadsDirectory, { recursive: true, force: true }) - } - // Check metadata and start restoring try { const metadataFile = zip.file("data/metadata.json") @@ -58,6 +53,12 @@ export async function restoreBackupAction(prevState: any, formData: FormData) { console.warn("No metadata found in backup, assuming legacy format") } + // Remove existing data + if (REMOVE_EXISTING_DATA) { + await cleanupUserTables(user.id) + await fs.rm(userUploadsDirectory, { recursive: true, force: true }) + } + const counters: Record = {} // Restore tables diff --git a/app/(app)/settings/backups/page.tsx b/app/(app)/settings/backups/page.tsx index 2709cea..10e668e 100644 --- a/app/(app)/settings/backups/page.tsx +++ b/app/(app)/settings/backups/page.tsx @@ -31,22 +31,25 @@ export default function BackupSettingsPage() {

Restore from a backup

- ⚠️ This action will delete all existing data from your current database and remove all uploaded files. Be - careful and make a backup first! + ⚠️ This action is irreversible. Restoring from a backup will delete all existing data from your current + database and remove all uploaded files. Be careful and make a backup first!

- +
diff --git a/app/(app)/unsorted/actions.ts b/app/(app)/unsorted/actions.ts index 18c3b43..a49cfac 100644 --- a/app/(app)/unsorted/actions.ts +++ b/app/(app)/unsorted/actions.ts @@ -50,7 +50,7 @@ export async function analyzeFileAction( prompt, schema, attachments, - config.selfHosted.isEnabled ? settings.openai_api_key : process.env.OPENAI_API_KEY || "" + settings.openai_api_key || config.ai.openaiApiKey ) console.log("Analysis results:", results) diff --git a/app/(auth)/self-hosted/page.tsx b/app/(auth)/self-hosted/page.tsx index d019da5..b564aa0 100644 --- a/app/(auth)/self-hosted/page.tsx +++ b/app/(auth)/self-hosted/page.tsx @@ -45,7 +45,7 @@ export default async function SelfHostedWelcomePage() {
- + Get your API key from{" "} diff --git a/docker-compose.production.yml b/docker-compose.production.yml index fb91005..0547de2 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -7,6 +7,8 @@ services: environment: - NODE_ENV=production - BASE_URL=https://taxhacker.app + - DISABLE_SIGNUP=true + - SELF_HOSTED_MODE=false - UPLOAD_PATH=/app/data/uploads env_file: - .env diff --git a/lib/config.ts b/lib/config.ts index ea379bf..2ec32b9 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -13,6 +13,9 @@ const config = { redirectUrl: "/self-hosted/redirect", welcomeUrl: "/self-hosted", }, + ai: { + openaiApiKey: process.env.OPENAI_API_KEY || "", + }, auth: { secret: process.env.BETTER_AUTH_SECRET || "please-set-secret", loginUrl: "/enter",