docs: add setup guides in English and Danish
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5ca984a018
commit
50c2664078
2 changed files with 246 additions and 0 deletions
123
OPSÆTNING.md
Normal file
123
OPSÆTNING.md
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
# FoamKing Opsætningsguide
|
||||||
|
|
||||||
|
Komplet vejledning til at sætte FoamKing prisberegneren i drift.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Forudsætninger
|
||||||
|
|
||||||
|
- **Node.js** 18 eller nyere (20 LTS anbefales)
|
||||||
|
- **npm** (følger med Node.js)
|
||||||
|
|
||||||
|
## 2. Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Konfiguration af miljøvariabler
|
||||||
|
|
||||||
|
Kopier eksempelfilen og udfyld med jeres egne værdier:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env.local
|
||||||
|
```
|
||||||
|
|
||||||
|
Åbn `.env.local` i en teksteditor og konfigurer hver sektion som beskrevet nedenfor.
|
||||||
|
|
||||||
|
### Admin-login (Påkrævet)
|
||||||
|
|
||||||
|
```env
|
||||||
|
ADMIN_EMAIL=admin@example.com
|
||||||
|
ADMIN_PASSWORD=changeme
|
||||||
|
```
|
||||||
|
|
||||||
|
Disse oplysninger bruges til at logge ind på `/intern/login`. Skift begge værdier inden I går i produktion.
|
||||||
|
|
||||||
|
### E-mail — Office 365 SMTP (Påkrævet)
|
||||||
|
|
||||||
|
```env
|
||||||
|
SMTP_HOST=smtp.office365.com
|
||||||
|
SMTP_PORT=587
|
||||||
|
SMTP_USER=tilbud@foamking.dk
|
||||||
|
SMTP_PASS=your_password_here
|
||||||
|
EMAIL_FROM_NAME=Foam King Prisberegner
|
||||||
|
EMAIL_TO=info@foamking.dk
|
||||||
|
```
|
||||||
|
|
||||||
|
Applikationen sender tilbudsforespørgsler via Office 365. For at det virker, skal **SMTP AUTH være aktiveret** på afsenderpostkassen:
|
||||||
|
|
||||||
|
1. Gå til **Exchange Admin Center** — [admin.exchange.microsoft.com](https://admin.exchange.microsoft.com)
|
||||||
|
2. Gå til **Recipients** → **Mailboxes**
|
||||||
|
3. Vælg postkassen **tilbud@foamking.dk**
|
||||||
|
4. Klik på **Manage email apps settings** (eller Mail flow → Email apps)
|
||||||
|
5. Aktivér **Authenticated SMTP (SMTP AUTH)**
|
||||||
|
6. Gem
|
||||||
|
|
||||||
|
> **Bemærk:** Hvis jeres organisation bruger Security Defaults eller Conditional Access-politikker, der blokerer legacy-godkendelse, kan det være nødvendigt at oprette en undtagelse for denne postkasse. Hvis MFA er aktiveret på kontoen, skal I bruge et App Password i stedet for den almindelige adgangskode.
|
||||||
|
|
||||||
|
### Base-URL (Påkrævet)
|
||||||
|
|
||||||
|
```env
|
||||||
|
NEXT_PUBLIC_BASE_URL=https://beregner.foamking.dk
|
||||||
|
```
|
||||||
|
|
||||||
|
Bruges når der genereres links i udgående e-mails (f.eks. links til tilbudssider).
|
||||||
|
|
||||||
|
### Afstandsberegning (Valgfrit)
|
||||||
|
|
||||||
|
```env
|
||||||
|
OPENROUTE_API_KEY=your_api_key_here
|
||||||
|
```
|
||||||
|
|
||||||
|
Uden denne nøgle bruger applikationen en indbygget afstandstabel baseret på postnumre, hvilket fungerer fint i de fleste tilfælde. Ønsker I mere præcise køreafstande, kan I oprette en gratis API-nøgle på [openrouteservice.org](https://openrouteservice.org/dev/#/signup) (2.000 forespørgsler pr. dag).
|
||||||
|
|
||||||
|
## 4. Opret database
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run setup
|
||||||
|
```
|
||||||
|
|
||||||
|
Dette opretter SQLite-databasen og de nødvendige tabeller.
|
||||||
|
|
||||||
|
## 5. Byg og start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
Applikationen starter på **port 3001**.
|
||||||
|
|
||||||
|
## 6. Ruteoversigt
|
||||||
|
|
||||||
|
| Rute | Beskrivelse |
|
||||||
|
| -------------------- | ---------------------------------------------- |
|
||||||
|
| `/` | Offentlig prisberegner |
|
||||||
|
| `/tilbud/[id]` | Offentlig tilbudsvisning (link fra e-mail) |
|
||||||
|
| `/intern` | Admin-dashboard — tilbudsstyring |
|
||||||
|
| `/intern/historik` | Admin — tilbudshistorik |
|
||||||
|
| `/intern/beregner` | Admin — detaljeret beregner med prisopbygning |
|
||||||
|
| `/intern/login` | Admin-loginside |
|
||||||
|
|
||||||
|
## 7. Tilpasset autentificering
|
||||||
|
|
||||||
|
Standardopsætningen bruger miljøvariablerne `ADMIN_EMAIL` og `ADMIN_PASSWORD` med sessioner i hukommelsen. Det er enkelt og tilstrækkeligt til en setup med en enkelt administrator.
|
||||||
|
|
||||||
|
Vil I integrere jeres egen autentificering (JWT, OAuth, SSO), skal I redigere **`lib/auth.ts`**. Hele applikationen bruger kun tre funktioner:
|
||||||
|
|
||||||
|
- `checkAuth()` — tjekker om den aktuelle forespørgsel er autentificeret
|
||||||
|
- `login(email, password)` — autentificerer en bruger og opretter en session
|
||||||
|
- `logout()` — afslutter den aktuelle session
|
||||||
|
|
||||||
|
Middlewaren i **`middleware.ts`** tjekker for en session-cookie på alle `/intern/*`-ruter og omdirigerer ikke-autentificerede besøgende til `/intern/login`. Opdater den, hvis I skifter til en anden mekanisme (f.eks. en JWT i en `Authorization`-header).
|
||||||
|
|
||||||
|
## 8. Udvikling
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev # Start udviklingsserver (port 3001)
|
||||||
|
npm run build # Produktionsbuild
|
||||||
|
npm start # Start produktionsserver
|
||||||
|
npm run lint # Kør ESLint
|
||||||
|
npm run setup # Opret / nulstil database
|
||||||
|
```
|
||||||
123
SETUP.md
Normal file
123
SETUP.md
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
# FoamKing Setup Guide
|
||||||
|
|
||||||
|
Complete setup instructions for deploying the FoamKing flooring price calculator.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Prerequisites
|
||||||
|
|
||||||
|
- **Node.js** 18 or later (20 LTS recommended)
|
||||||
|
- **npm** (included with Node.js)
|
||||||
|
|
||||||
|
## 2. Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Configure Environment
|
||||||
|
|
||||||
|
Copy the example file and fill in your values:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env.local
|
||||||
|
```
|
||||||
|
|
||||||
|
Open `.env.local` in a text editor and configure each section as described below.
|
||||||
|
|
||||||
|
### Admin Login (Required)
|
||||||
|
|
||||||
|
```env
|
||||||
|
ADMIN_EMAIL=admin@example.com
|
||||||
|
ADMIN_PASSWORD=changeme
|
||||||
|
```
|
||||||
|
|
||||||
|
These credentials are used to sign in at `/intern/login`. Change both values before going to production.
|
||||||
|
|
||||||
|
### Email — Office 365 SMTP (Required)
|
||||||
|
|
||||||
|
```env
|
||||||
|
SMTP_HOST=smtp.office365.com
|
||||||
|
SMTP_PORT=587
|
||||||
|
SMTP_USER=tilbud@foamking.dk
|
||||||
|
SMTP_PASS=your_password_here
|
||||||
|
EMAIL_FROM_NAME=Foam King Prisberegner
|
||||||
|
EMAIL_TO=info@foamking.dk
|
||||||
|
```
|
||||||
|
|
||||||
|
The application sends quote-request emails through Office 365. For this to work, **SMTP AUTH must be enabled** on the sending mailbox:
|
||||||
|
|
||||||
|
1. Go to **Exchange Admin Center** — [admin.exchange.microsoft.com](https://admin.exchange.microsoft.com)
|
||||||
|
2. Navigate to **Recipients** → **Mailboxes**
|
||||||
|
3. Select the **tilbud@foamking.dk** mailbox
|
||||||
|
4. Click **Manage email apps settings** (or Mail flow → Email apps)
|
||||||
|
5. Enable **Authenticated SMTP (SMTP AUTH)**
|
||||||
|
6. Save
|
||||||
|
|
||||||
|
> **Note:** If your organization uses Security Defaults or Conditional Access policies that block legacy authentication, you may need to create an exclusion for this mailbox. If MFA is enabled on the account, use an App Password instead of the regular password.
|
||||||
|
|
||||||
|
### Base URL (Required)
|
||||||
|
|
||||||
|
```env
|
||||||
|
NEXT_PUBLIC_BASE_URL=https://beregner.foamking.dk
|
||||||
|
```
|
||||||
|
|
||||||
|
Used when generating links in outgoing emails (e.g. links to quote pages).
|
||||||
|
|
||||||
|
### Distance Calculation (Optional)
|
||||||
|
|
||||||
|
```env
|
||||||
|
OPENROUTE_API_KEY=your_api_key_here
|
||||||
|
```
|
||||||
|
|
||||||
|
Without this key the application uses a built-in postal code distance table, which is perfectly fine for most cases. If you want more precise driving distances, sign up for a free API key at [openrouteservice.org](https://openrouteservice.org/dev/#/signup) (2,000 requests per day).
|
||||||
|
|
||||||
|
## 4. Initialize Database
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run setup
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates the SQLite database and required tables.
|
||||||
|
|
||||||
|
## 5. Build and Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
The application starts on **port 3001**.
|
||||||
|
|
||||||
|
## 6. Route Overview
|
||||||
|
|
||||||
|
| Route | Description |
|
||||||
|
| -------------------- | -------------------------------------------- |
|
||||||
|
| `/` | Public price calculator |
|
||||||
|
| `/tilbud/[id]` | Public quote view (linked from email) |
|
||||||
|
| `/intern` | Admin dashboard — quote management |
|
||||||
|
| `/intern/historik` | Admin — quote history |
|
||||||
|
| `/intern/beregner` | Admin — detailed calculator with price breakdown |
|
||||||
|
| `/intern/login` | Admin login page |
|
||||||
|
|
||||||
|
## 7. Custom Authentication
|
||||||
|
|
||||||
|
The default authentication uses the `ADMIN_EMAIL` and `ADMIN_PASSWORD` environment variables with in-memory sessions. This is simple and sufficient for a single-admin setup.
|
||||||
|
|
||||||
|
To integrate your own authentication (JWT, OAuth, SSO), edit **`lib/auth.ts`**. The entire application relies on only three functions:
|
||||||
|
|
||||||
|
- `checkAuth()` — checks whether the current request is authenticated
|
||||||
|
- `login(email, password)` — authenticates a user and creates a session
|
||||||
|
- `logout()` — destroys the current session
|
||||||
|
|
||||||
|
The middleware in **`middleware.ts`** checks for a session cookie on all `/intern/*` routes and redirects unauthenticated visitors to `/intern/login`. Update it if you switch to a different mechanism (e.g. a JWT in an `Authorization` header).
|
||||||
|
|
||||||
|
## 8. Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev # Start development server (port 3001)
|
||||||
|
npm run build # Production build
|
||||||
|
npm start # Start production server
|
||||||
|
npm run lint # Run ESLint
|
||||||
|
npm run setup # Initialize / reset database
|
||||||
|
```
|
||||||
Loading…
Add table
Reference in a new issue