Skip to content

Commit 5f2fd98

Browse files
committed
chore(examples): prettier on dashboard codebase
1 parent dfe15ee commit 5f2fd98

File tree

33 files changed

+722
-614
lines changed

33 files changed

+722
-614
lines changed

examples/demos/dashboard-integration/README.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,35 @@ A Next.js application demonstrating how to integrate Outpost with an API platfor
1919
## Setup
2020

2121
1. **Clone and navigate to the project**:
22+
2223
```bash
2324
cd examples/demos/dashboard-integration
2425
```
2526

2627
2. **Install dependencies**:
28+
2729
```bash
2830
npm install
2931
```
3032

3133
3. **Set up environment variables**:
34+
3235
```bash
3336
# Dashboard application configuration
3437
cp .env.example .env.local
35-
38+
3639
# Outpost configuration
3740
cp .env.outpost.example .env.outpost
3841
```
39-
42+
4043
The default configurations should work for local development. For production, update the secrets in both files.
4144

4245
4. **Start the complete stack** (PostgreSQL, Redis, RabbitMQ, and Outpost):
46+
4347
```bash
4448
docker-compose up -d
4549
```
46-
50+
4751
This will start:
4852
- `postgres` - PostgreSQL with separate databases for dashboard and Outpost (port 5432)
4953
- `redis` - Redis for Outpost (port 6379)
@@ -53,12 +57,15 @@ A Next.js application demonstrating how to integrate Outpost with an API platfor
5357
- `outpost-log` - Outpost log service
5458

5559
5. **Wait for services to be healthy**:
60+
5661
```bash
5762
docker-compose ps
5863
```
64+
5965
Wait until all services show "healthy" status. This may take 1-2 minutes on first startup.
6066

6167
6. **Run the dashboard application**:
68+
6269
```bash
6370
npm run dev
6471
```
@@ -95,25 +102,25 @@ This demo represents a common integration scenario where:
95102

96103
### Dashboard Application (.env.local)
97104

98-
| Variable | Description | Example |
99-
|----------|-------------|---------|
100-
| `DATABASE_URL` | Dashboard PostgreSQL connection | `postgresql://dashboard:dashboard@localhost:5432/dashboard_integration` |
101-
| `NEXTAUTH_SECRET` | Auth.js secret key | `your-secret-here` |
102-
| `OUTPOST_BASE_URL` | Outpost base URL | `http://localhost:3333` |
103-
| `OUTPOST_API_KEY` | Outpost API key | `demo-api-key-change-in-production` |
104-
| `LOG_LEVEL` | Application logging level (`error`, `warn`, `info`, `debug`) | `info` |
105+
| Variable | Description | Example |
106+
| ------------------ | ------------------------------------------------------------ | ----------------------------------------------------------------------- |
107+
| `DATABASE_URL` | Dashboard PostgreSQL connection | `postgresql://dashboard:dashboard@localhost:5432/dashboard_integration` |
108+
| `NEXTAUTH_SECRET` | Auth.js secret key | `your-secret-here` |
109+
| `OUTPOST_BASE_URL` | Outpost base URL | `http://localhost:3333` |
110+
| `OUTPOST_API_KEY` | Outpost API key | `demo-api-key-change-in-production` |
111+
| `LOG_LEVEL` | Application logging level (`error`, `warn`, `info`, `debug`) | `info` |
105112

106113
### Outpost Configuration (.env.outpost)
107114

108-
| Variable | Description | Example |
109-
|----------|-------------|---------|
110-
| `API_KEY` | Outpost API key | `demo-api-key-change-in-production` |
111-
| `API_JWT_SECRET` | JWT signing secret | `demo-jwt-secret-change-in-production` |
112-
| `POSTGRES_URL` | Outpost PostgreSQL connection | `postgres://outpost:outpost@postgres:5432/outpost` |
113-
| `REDIS_HOST` | Redis hostname | `redis` |
114-
| `RABBITMQ_SERVER_URL` | RabbitMQ connection | `amqp://guest:guest@rabbitmq:5672` |
115-
| `PORTAL_ORGANIZATION_NAME` | Portal branding | `API Platform Demo` |
116-
| `PORTAL_REFERER_URL` | Dashboard URL for "Back to" navigation link in portal | `http://localhost:3000` |
115+
| Variable | Description | Example |
116+
| -------------------------- | ----------------------------------------------------- | -------------------------------------------------- |
117+
| `API_KEY` | Outpost API key | `demo-api-key-change-in-production` |
118+
| `API_JWT_SECRET` | JWT signing secret | `demo-jwt-secret-change-in-production` |
119+
| `POSTGRES_URL` | Outpost PostgreSQL connection | `postgres://outpost:outpost@postgres:5432/outpost` |
120+
| `REDIS_HOST` | Redis hostname | `redis` |
121+
| `RABBITMQ_SERVER_URL` | RabbitMQ connection | `amqp://guest:guest@rabbitmq:5672` |
122+
| `PORTAL_ORGANIZATION_NAME` | Portal branding | `API Platform Demo` |
123+
| `PORTAL_REFERER_URL` | Dashboard URL for "Back to" navigation link in portal | `http://localhost:3000` |
117124

118125
## Docker Services
119126

@@ -139,6 +146,7 @@ The docker-compose.yml includes the complete stack:
139146
## Troubleshooting
140147

141148
### Services not starting
149+
142150
```bash
143151
# Check service status
144152
docker-compose ps
@@ -152,13 +160,15 @@ docker-compose restart
152160
```
153161

154162
### Database connection issues
163+
155164
```bash
156165
# Check PostgreSQL is ready
157166
docker-compose exec postgres pg_isready -U dashboard -d dashboard_integration
158167
docker-compose exec postgres pg_isready -U outpost -d outpost
159168
```
160169

161170
### Outpost API not responding
171+
162172
```bash
163173
# Check if Outpost API is healthy
164174
curl http://localhost:3333/healthz

examples/demos/dashboard-integration/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3.8'
1+
version: "3.8"
22

33
services:
44
# Shared PostgreSQL instance with multiple databases
@@ -41,7 +41,7 @@ services:
4141
image: rabbitmq:3-management
4242
ports:
4343
- "5672:5672"
44-
- "15672:15672" # Management UI
44+
- "15672:15672" # Management UI
4545
volumes:
4646
- rabbitmq_data:/var/lib/rabbitmq
4747
healthcheck:
@@ -122,4 +122,4 @@ services:
122122
volumes:
123123
postgres_data:
124124
redis_data:
125-
rabbitmq_data:
125+
rabbitmq_data:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { handlers } from '@/lib/auth'
1+
import { handlers } from "@/lib/auth";
22

3-
export const { GET, POST } = handlers
3+
export const { GET, POST } = handlers;
Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,77 @@
1-
import { NextRequest, NextResponse } from 'next/server'
2-
import { createUser, getUserByEmail } from '../../../../lib/db'
3-
import { createTenant } from '../../../../lib/outpost'
4-
import { generateTenantId } from '../../../../lib/utils'
5-
import { registerSchema } from '../../../../lib/validations'
6-
import logger from '../../../../lib/logger'
1+
import { NextRequest, NextResponse } from "next/server";
2+
import { createUser, getUserByEmail } from "../../../../lib/db";
3+
import { createTenant } from "../../../../lib/outpost";
4+
import { generateTenantId } from "../../../../lib/utils";
5+
import { registerSchema } from "../../../../lib/validations";
6+
import logger from "../../../../lib/logger";
77

88
export async function POST(request: NextRequest) {
99
try {
10-
const body = await request.json()
11-
const validatedData = registerSchema.parse(body)
10+
const body = await request.json();
11+
const validatedData = registerSchema.parse(body);
1212

1313
// Check if user already exists
14-
const existingUser = await getUserByEmail(validatedData.email)
14+
const existingUser = await getUserByEmail(validatedData.email);
1515
if (existingUser) {
1616
return NextResponse.json(
17-
{ message: 'User already exists' },
18-
{ status: 400 }
19-
)
17+
{ message: "User already exists" },
18+
{ status: 400 },
19+
);
2020
}
2121

2222
// Create user in database
2323
const user = await createUser({
2424
email: validatedData.email,
2525
name: validatedData.name,
26-
})
26+
});
2727

2828
// Create tenant in Outpost using the user ID
29-
const tenantId = generateTenantId(user.id.toString())
30-
logger.info(`Creating Outpost tenant for new user registration`, {
31-
userId: user.id,
32-
tenantId,
33-
email: validatedData.email
34-
})
35-
29+
const tenantId = generateTenantId(user.id.toString());
30+
logger.info(`Creating Outpost tenant for new user registration`, {
31+
userId: user.id,
32+
tenantId,
33+
email: validatedData.email,
34+
});
35+
3636
try {
37-
await createTenant(tenantId)
38-
logger.info(`User registration completed successfully with Outpost tenant`, {
39-
userId: user.id,
40-
tenantId,
41-
email: validatedData.email
42-
})
37+
await createTenant(tenantId);
38+
logger.info(
39+
`User registration completed successfully with Outpost tenant`,
40+
{
41+
userId: user.id,
42+
tenantId,
43+
email: validatedData.email,
44+
},
45+
);
4346
} catch (outpostError) {
44-
logger.error('Failed to create Outpost tenant during registration', {
47+
logger.error("Failed to create Outpost tenant during registration", {
4548
error: outpostError,
4649
tenantId,
4750
userId: user.id,
48-
email: validatedData.email
49-
})
51+
email: validatedData.email,
52+
});
5053
// Continue with registration even if tenant creation fails
5154
// In production, you might want to retry or handle this differently
5255
}
5356

5457
return NextResponse.json(
55-
{ message: 'User created successfully' },
56-
{ status: 201 }
57-
)
58+
{ message: "User created successfully" },
59+
{ status: 201 },
60+
);
5861
} catch (error: any) {
59-
logger.error('Registration error', { error, errorMessage: error?.message })
60-
62+
logger.error("Registration error", { error, errorMessage: error?.message });
63+
6164
if (error.errors) {
6265
// Validation error
6366
return NextResponse.json(
64-
{ message: 'Validation failed', errors: error.errors },
65-
{ status: 400 }
66-
)
67+
{ message: "Validation failed", errors: error.errors },
68+
{ status: 400 },
69+
);
6770
}
6871

6972
return NextResponse.json(
70-
{ message: 'Internal server error' },
71-
{ status: 500 }
72-
)
73+
{ message: "Internal server error" },
74+
{ status: 500 },
75+
);
7376
}
74-
}
77+
}
Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
1-
import { NextRequest, NextResponse } from 'next/server'
2-
import { getToken } from 'next-auth/jwt'
3-
import { getTenantOverview } from '../../../lib/outpost'
4-
import logger from '../../../lib/logger'
1+
import { NextRequest, NextResponse } from "next/server";
2+
import { getToken } from "next-auth/jwt";
3+
import { getTenantOverview } from "../../../lib/outpost";
4+
import logger from "../../../lib/logger";
55

66
export async function GET(request: NextRequest) {
77
try {
88
// Validate session using JWT token
9-
const token = await getToken({
9+
const token = await getToken({
1010
req: request,
11-
secret: process.env.NEXTAUTH_SECRET
12-
})
13-
11+
secret: process.env.NEXTAUTH_SECRET,
12+
});
13+
1414
if (!token?.id) {
15-
return NextResponse.json(
16-
{ error: 'Unauthorized' },
17-
{ status: 401 }
18-
)
15+
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
1916
}
20-
17+
2118
// Use the user ID directly as the tenant ID
22-
const tenantId = token.id as string
23-
19+
const tenantId = token.id as string;
20+
2421
// Get tenant overview from Outpost
25-
const overview = await getTenantOverview(tenantId)
26-
27-
return NextResponse.json(overview)
22+
const overview = await getTenantOverview(tenantId);
23+
24+
return NextResponse.json(overview);
2825
} catch (error) {
29-
logger.error('Overview API error', { error })
30-
26+
logger.error("Overview API error", { error });
27+
3128
return NextResponse.json(
32-
{ error: 'Failed to fetch overview data' },
33-
{ status: 500 }
34-
)
29+
{ error: "Failed to fetch overview data" },
30+
{ status: 500 },
31+
);
3532
}
36-
}
33+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import LoginForm from '@/components/auth/LoginForm'
1+
import LoginForm from "@/components/auth/LoginForm";
22

33
export default function LoginPage() {
4-
return <LoginForm />
5-
}
4+
return <LoginForm />;
5+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import RegisterForm from '@/components/auth/RegisterForm'
1+
import RegisterForm from "@/components/auth/RegisterForm";
22

33
export default function RegisterPage() {
4-
return <RegisterForm />
5-
}
4+
return <RegisterForm />;
5+
}

0 commit comments

Comments
 (0)