Skip to content

Commit d5d991a

Browse files
author
Scott Kurtzeborn
committed
Make documentation generic and add CLI options
1 parent 93e9719 commit d5d991a

File tree

4 files changed

+146
-254
lines changed

4 files changed

+146
-254
lines changed

GETTING-STARTED.md

Lines changed: 20 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,23 @@
11
# Getting Started Guide
22

3-
This guide will walk you through setting up the URL shortener from scratch.
3+
This guide will help you set up the URL shortener for local development or production deployment.
44

5-
## Prerequisites
5+
## Quick Start
66

7-
- Azure subscription (free tier)
8-
- Cloudflare account (free tier)
9-
- GitHub account
10-
- Node.js 20+ installed
11-
- Azure CLI installed
12-
- Wrangler CLI installed (`npm install -g wrangler`)
7+
1. **Clone and Install**
8+
```bash
9+
git clone https://github.com/yourusername/url-shortener.git
10+
cd url-shortener
11+
npm ci # Install dependencies from lock file
12+
```
1313

14-
## Step 1: Clone and Install
14+
2. **For Local Development** → Continue to [Local Development](#local-development) below
1515

16-
```bash
17-
git clone https://github.com/kurtzeborn/url-shortener.git
18-
cd url-shortener
19-
npm ci # Install dependencies from lock file
20-
```
21-
22-
## Step 2: Azure Setup
23-
24-
### 2.1 Create Storage Account
25-
26-
```bash
27-
# Login to Azure
28-
az login
29-
30-
# Create resource group
31-
az group create --name url-shortener-rg --location eastus
32-
33-
# Create storage account
34-
az storage account create \
35-
--name k61urlshortener \
36-
--resource-group url-shortener-rg \
37-
--location eastus \
38-
--sku Standard_LRS
39-
40-
# Get connection string (save this!)
41-
az storage account show-connection-string \
42-
--name k61urlshortener \
43-
--resource-group url-shortener-rg
44-
```
45-
46-
### 2.2 Create Tables
47-
48-
Go to Azure Portal → Storage Account → Table Storage and create:
49-
- `URLs`
50-
- `UserURLs`
51-
- `AllowedUsers`
52-
- `UserInvites`
53-
54-
### 2.3 Add First User
55-
56-
In Azure Portal → Table Storage → `AllowedUsers` table:
57-
- Click "Add Entity"
58-
- PartitionKey: `users`
59-
- RowKey: `your@email.com`
60-
- AddedDate: Current date/time
61-
- AddedBy: `system`
62-
63-
### 2.4 Create Function App
64-
65-
```bash
66-
az functionapp create \
67-
--resource-group url-shortener-rg \
68-
--consumption-plan-location eastus \
69-
--runtime node \
70-
--runtime-version 20 \
71-
--functions-version 4 \
72-
--name k61-url-functions \
73-
--storage-account k61urlshortener
74-
75-
# Get publish profile (save for GitHub secrets)
76-
az functionapp deployment list-publishing-profiles \
77-
--name k61-url-functions \
78-
--resource-group url-shortener-rg \
79-
--xml
80-
```
81-
82-
### 2.5 Create Static Web Apps
83-
84-
```bash
85-
# For url.k61.dev (web app)
86-
az staticwebapp create \
87-
--name k61-url-web \
88-
--resource-group url-shortener-rg \
89-
--location eastus2
90-
91-
# Get deployment token (save for GitHub secrets)
92-
az staticwebapp secrets list \
93-
--name k61-url-web \
94-
--resource-group url-shortener-rg
95-
```
96-
97-
## Step 3: Cloudflare Setup
98-
99-
### 3.1 Add Domain to Cloudflare
100-
101-
1. Go to Cloudflare Dashboard
102-
2. Click "Add a Site"
103-
3. Enter `k61.dev`
104-
4. Choose Free plan
105-
5. Update Namecheap nameservers to Cloudflare's
106-
107-
### 3.2 Configure DNS
108-
109-
Add these DNS records in Cloudflare:
110-
- `k61.dev` → CNAME to your Worker (will be set after deployment)
111-
- `url` → CNAME to Azure Static Web App (from Step 2.5)
112-
- `www` → CNAME to Azure Static Web App (from Step 2.5)
16+
3. **For Production Deployment** → See [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md)
11317

114-
### 3.3 Get API Token
18+
---
11519

116-
1. Cloudflare Dashboard → My Profile → API Tokens
117-
2. Create Token → Edit Cloudflare Workers template
118-
3. Save token for GitHub secrets
119-
120-
## Step 4: GitHub Secrets
121-
122-
Add these secrets in GitHub repository settings:
123-
124-
### Cloudflare Worker
125-
- `CLOUDFLARE_API_TOKEN` - API token from Step 3.3
126-
- `DEFAULT_URL` - URL to redirect unknown/invalid IDs (e.g., https://url.k61.dev)
127-
- `AZURE_STORAGE_ACCOUNT` - Storage account name (k61urlshortener)
128-
- `AZURE_STORAGE_SAS` - SAS token from Azure Portal → Storage Account → Shared access signature
129-
- `AZURE_API_URL` - Azure Functions URL (e.g., https://k61-url-functions.azurewebsites.net)
130-
- `INTERNAL_API_KEY` - Generate a random secure key (e.g., `openssl rand -hex 32`)
131-
132-
### Azure Functions
133-
- `AZURE_FUNCTIONAPP_NAME` - Function app name (k61-url-functions)
134-
- `AZURE_FUNCTIONAPP_PUBLISH_PROFILE` - XML from Step 2.4
135-
136-
### Azure Static Web Apps
137-
- `AZURE_STATIC_WEB_APPS_API_TOKEN_WEB` - Token from Step 2.5
138-
- `VITE_MICROSOFT_CLIENT_ID` - Microsoft Entra app registration client ID
139-
- `VITE_API_URL` - Azure Functions URL (e.g., https://k61-url-functions.azurewebsites.net)
140-
141-
## Step 5: Local Development
20+
## Local Development
14221

14322
### Functions
14423

@@ -159,51 +38,16 @@ npm install
15938
npm run dev # Runs on http://localhost:5173
16039
```
16140

162-
### Cloudflare Worker
163-
164-
```bash
165-
cd workers
166-
npm install
167-
wrangler dev # Runs on http://localhost:8787
168-
```
169-
170-
## Step 6: Deploy
171-
172-
Push to main branch to trigger automatic deployments:
173-
174-
```bash
175-
git add .
176-
git commit -m "Initial setup"
177-
git push origin main
178-
```
179-
180-
GitHub Actions will automatically deploy:
181-
- Cloudflare Worker
182-
- Azure Functions
183-
- Web App (url.k61.dev)
184-
185-
## Step 7: Configure Custom Domains
186-
187-
### In Azure Portal
41+
---
18842

189-
For each Static Web App:
190-
1. Go to Custom Domains
191-
2. Add domain (url.k61.dev and www.k61.dev)
192-
3. Follow validation instructions
43+
## Testing Locally
19344

194-
### In Cloudflare
45+
1. Ensure Functions are running (`http://localhost:7071`)
46+
2. Visit web app (`http://localhost:5173`)
47+
3. Login with your allowlisted email
48+
4. Create a test shortened URL
19549

196-
1. Ensure DNS records are set correctly
197-
2. Enable "Proxied" mode for k61.dev
198-
3. Configure Worker route: `k61.dev/*`
199-
200-
## Testing
201-
202-
1. Visit `https://url.k61.dev` - Should show login page
203-
2. Login with your allowlisted email
204-
3. Create a test shortened URL
205-
4. Visit `https://k61.dev/<id>` - Should redirect
206-
5. Check dashboard - Click count should increment
50+
---
20751

20852
## Troubleshooting
20953

@@ -220,20 +64,4 @@ For each Static Web App:
22064
### Static Web Apps not deploying
22165
- Check GitHub Actions logs
22266
- Verify deployment tokens are correct
223-
- Check build output in Actions
224-
225-
## Next Steps
226-
227-
- [x] ~~Implement Microsoft OAuth authentication~~ (Done)
228-
- [x] ~~Add comprehensive tests~~ (Done - 51 tests)
229-
- [ ] Set up monitoring/alerts
230-
- [ ] [Add URL analytics dashboard](https://github.com/kurtzeborn/url-shortener/issues/4)
231-
- [ ] [Implement custom aliases](https://github.com/kurtzeborn/url-shortener/issues/3)
232-
- [ ] [Add QR code generation](https://github.com/kurtzeborn/url-shortener/issues/8)
233-
234-
## Support
235-
236-
For issues, check:
237-
- GitHub Issues: https://github.com/kurtzeborn/url-shortener/issues
238-
- [docs/archive/PLAN.md](docs/archive/PLAN.md) for original architecture details
239-
- Individual component READMEs
67+
- Check build output in Actions

docs/API.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# URL Shortener API Documentation
22

3-
Base URL: `https://api.k61.dev` (production) or `http://localhost:7071` (development)
3+
Base URL: `https://<your-function-app>.azurewebsites.net` (production) or `http://localhost:7071` (development)
44

55
## Authentication
66

@@ -59,7 +59,7 @@ POST /api/urls
5959
```json
6060
{
6161
"id": "aBc1",
62-
"shortUrl": "https://k61.dev/aBc1",
62+
"shortUrl": "https://yourdomain.com/aBc1",
6363
"url": "https://example.com/long/url",
6464
"createdAt": "2026-01-16T12:00:00.000Z",
6565
"clickCount": 0
@@ -87,7 +87,7 @@ GET /api/urls
8787
"urls": [
8888
{
8989
"id": "aBc1",
90-
"shortUrl": "https://k61.dev/aBc1",
90+
"shortUrl": "https://yourdomain.com/aBc1",
9191
"url": "https://example.com/long/url",
9292
"createdAt": "2026-01-16T12:00:00.000Z",
9393
"clickCount": 42
@@ -115,7 +115,7 @@ GET /api/urls/{id}
115115
```json
116116
{
117117
"id": "aBc1",
118-
"shortUrl": "https://k61.dev/aBc1",
118+
"shortUrl": "https://yourdomain.com/aBc1",
119119
"url": "https://example.com/long/url",
120120
"createdAt": "2026-01-16T12:00:00.000Z",
121121
"clickCount": 42
@@ -140,7 +140,7 @@ PUT /api/urls/{id}
140140
```json
141141
{
142142
"id": "aBc1",
143-
"shortUrl": "https://k61.dev/aBc1",
143+
"shortUrl": "https://yourdomain.com/aBc1",
144144
"url": "https://example.com/new/url",
145145
"updatedAt": "2026-01-16T13:00:00.000Z"
146146
}
@@ -229,6 +229,6 @@ X-Internal-Key: <INTERNAL_API_KEY>
229229

230230
| Variable | Description |
231231
|----------|-------------|
232-
| `SHORT_URL_DOMAIN` | Domain for short URLs (default: `k61.dev`) |
232+
| `SHORT_URL_DOMAIN` | Domain for short URLs (e.g., `yourdomain.com`) |
233233
| `AZURE_STORAGE_CONNECTION_STRING` | Azure Table Storage connection |
234234
| `INTERNAL_API_KEY` | Key for internal API authentication |

docs/AUTH_SETUP.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Authentication Setup Guide
22

3-
## Azure AD App Registration
3+
This guide covers Microsoft authentication configuration in detail. For the complete deployment process, see [DEPLOYMENT.md](DEPLOYMENT.md).
44

5-
To enable Microsoft authentication, you need to register an application in Azure AD:
5+
## Microsoft Entra ID App Registration
6+
7+
To enable Microsoft authentication, you need to register an application in Microsoft Entra ID:
68

79
### Step 1: Create App Registration
810
1. Go to [Azure Portal](https://portal.azure.com)
9-
2. Navigate to **Azure Active Directory** > **App registrations**
11+
2. Navigate to **Microsoft Entra ID** > **App registrations**
1012
3. Click **New registration**
1113
4. Fill in:
12-
- **Name**: `URL Shortener (k61.dev)`
14+
- **Name**: `URL Shortener`
1315
- **Supported account types**: Select one of:
1416
- "Personal Microsoft accounts only" (if only personal accounts)
1517
- "Accounts in any organizational directory and personal Microsoft accounts" (if both work and personal)
@@ -20,7 +22,7 @@ To enable Microsoft authentication, you need to register an application in Azure
2022
### Step 2: Configure Redirect URIs
2123
After creation, go to **Authentication** and add:
2224
- `http://localhost:5173` (local development)
23-
- `https://url.k61.dev` (production)
25+
- `https://url.yourdomain.com` (production - replace with your actual domain)
2426

2527
### Step 3: Get Client ID
2628
1. Go to the app's **Overview** page

0 commit comments

Comments
 (0)