Skip to content

Commit 10dcb29

Browse files
committed
feat(add): improved bucket provider support
1 parent 6f18826 commit 10dcb29

29 files changed

Lines changed: 3720 additions & 1142 deletions

File tree

.claude/commands/add-api-route.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# add-api-route
2+
3+
Scaffold a new API route following Emberly's conventions.
4+
5+
## Pattern
6+
7+
```ts
8+
// app/api/<path>/route.ts
9+
import { HTTP_STATUS, apiError, apiResponse } from '@/packages/lib/api/response'
10+
import { requireAdmin } from '@/packages/lib/auth/api-auth' // or requireAuth for user-level
11+
import { prisma } from '@/packages/lib/database/prisma'
12+
import { loggers } from '@/packages/lib/logger'
13+
14+
const logger = loggers.api // pick the right logger namespace
15+
16+
export async function GET(req: Request) {
17+
try {
18+
const { response, session } = await requireAdmin(req) // or requireAuth
19+
if (response) return response
20+
21+
// ... handler logic ...
22+
23+
return apiResponse(data)
24+
} catch (error) {
25+
logger.error('Failed to ...', error as Error)
26+
return apiError('Internal server error', HTTP_STATUS.INTERNAL_SERVER_ERROR)
27+
}
28+
}
29+
```
30+
31+
## Auth helpers
32+
33+
| Helper | Use when |
34+
| ------------------- | ---------------------------------------------- |
35+
| `requireAdmin(req)` | Admin panel routes — user must have ADMIN role |
36+
| `requireAuth(req)` | Authenticated user routes |
37+
| `verifyApiKey(req)` | API key auth (programmatic access) |
38+
39+
## Rules
40+
41+
- Always wrap in try/catch and return `apiError('Internal server error')` on unexpected failures.
42+
- Never return raw S3 secrets or sensitive credentials.
43+
- Validate and sanitise body input before using it in DB queries.
44+
- Use `prisma` from `@/packages/lib/database/prisma`, never instantiate a new client.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# add-integration
2+
3+
Add a new third-party integration (API key / credentials) to Emberly's configuration system.
4+
5+
## What to do
6+
7+
1. **Add the Zod schema** in `packages/lib/config/index.ts` under `settings.integrations`:
8+
9+
```ts
10+
myservice: z.object({
11+
apiKey: z.string().optional().default(''),
12+
}).passthrough().optional().default({}),
13+
```
14+
15+
2. **Add the default value** in the `DEFAULT_CONFIG` object in the same file:
16+
17+
```ts
18+
myservice: { apiKey: '' },
19+
```
20+
21+
3. **Create the API client** at `packages/lib/storage/providers/myservice.ts` (for storage providers)
22+
or `packages/lib/myservice/index.ts` for other services, following the same auth pattern as
23+
`packages/lib/storage/providers/vultr.ts`:
24+
- Read credentials via `getIntegrations()` with env var fallback
25+
- Validate and build URLs safely before fetching
26+
27+
4. **Wire up the admin UI** — the settings manager (`packages/components/admin/settings/settings-manager.tsx`)
28+
has sections per integration. Add an API key input field and a test button following the
29+
existing Vultr pattern.
30+
31+
5. **Document the env var fallback** in `.env.template` as a comment.

.claude/commands/db-migrate.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# db-migrate
2+
3+
Run a Prisma migration for the current schema changes.
4+
5+
## Steps
6+
7+
1. Ask the user for a short migration name that describes what changed (e.g. `add-object-storage-pool`, `add-user-avatar-field`).
8+
2. Run the migration:
9+
```bash
10+
yarn db:migrate --name <migration-name>
11+
```
12+
3. Run `yarn db:generate` to update the Prisma client.
13+
4. Report the new migration file created under `prisma/migrations/`.
14+
15+
If `yarn db:migrate` fails due to a destructive change (dropping a column, renaming), explain the impact and ask whether to proceed with `--create-only` so the SQL can be reviewed first.

.claude/commands/lint.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# lint
2+
3+
Run ESLint across the project and auto-fix what can be fixed.
4+
5+
```bash
6+
yarn lint:fix
7+
```
8+
9+
Then verify no remaining errors:
10+
11+
```bash
12+
yarn lint
13+
```
14+
15+
Key rules to be aware of:
16+
17+
- `@typescript-eslint/no-explicit-any` is a **warning** (not error) — minimise `any` but don't panic.
18+
- `react/no-unescaped-entities` is **off** — apostrophes in JSX are fine.
19+
- `@next/next/no-img-element` is **off**`<img>` is allowed.
20+
- Unused variables are warned if not prefixed with `_`.

.claude/commands/typecheck.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# typecheck
2+
3+
Run TypeScript type checking across the entire project without emitting files.
4+
5+
```bash
6+
yarn typecheck
7+
```
8+
9+
If there are errors, fix them before considering any task complete. Pay attention to:
10+
11+
- Prisma model field names (regenerate the client with `yarn db:generate` if model types are stale)
12+
- Import path aliases (`@/packages/lib/...` not relative paths)
13+
- `unknown` vs `any` — prefer narrowing over casting

.claude/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(yarn:*)",
5+
"Bash(npx prisma:*)",
6+
"Bash(npx tsx:*)",
7+
"Bash(git diff:*)",
8+
"Bash(git log:*)",
9+
"Bash(git status:*)",
10+
"Bash(git show:*)"
11+
]
12+
}
13+
}

.github/workflows/socket.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Socket Security
2+
3+
on:
4+
push:
5+
branches: [ master, dev ]
6+
pull_request:
7+
branches: [ master, dev ]
8+
9+
jobs:
10+
socket-scan:
11+
name: Supply Chain Security
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
# Required to post PR comments and check run results
16+
pull-requests: write
17+
checks: write
18+
19+
steps:
20+
- uses: actions/checkout@v6
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v6
24+
with:
25+
node-version: 22
26+
27+
- name: Socket Security Scan
28+
uses: SocketDev/socket-action@v1
29+
with:
30+
api_key: ${{ secrets.SOCKET_SECURITY_API_KEY }}
31+
# Fail the workflow if any issue reaches the "error" action level in socket.yml
32+
# (malware, install scripts, obfuscated files, typosquatting, new authors, env exfil)
33+
fail_on_error: true

0 commit comments

Comments
 (0)