Skip to content

Commit ba18023

Browse files
author
Pau Tena
committed
Generate next client
1 parent 36b0453 commit ba18023

File tree

9 files changed

+816
-15
lines changed

9 files changed

+816
-15
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ SENTRY_DSN="op://Environments/My Full-Stack Template/SENTRY_DSN"
4040
# Configure these with your own Docker registry images
4141
DOCKER_IMAGE_BACKEND="op://Environments/My Full-Stack Template/$ENVIRONMENT/DOCKER_IMAGE_BACKEND"
4242
DOCKER_IMAGE_FRONTEND="op://Environments/My Full-Stack Template/$ENVIRONMENT/DOCKER_IMAGE_FRONTEND"
43+
44+
45+
## NextJS
46+
NEXT_AUTH_SECRET="op://Environments/My Full-Stack Template/NEXT_AUTH_SECRET"

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ playwright:
1616
cd frontend; \
1717
op run --env-file="../.env" -- npx playwright test --fail-on-flaky-tests --trace=retain-on-failure;
1818

19-
.PHONY: watch up build playwright
19+
generate-client:
20+
op run --env-file=".env" -- ./scripts/generate-client.sh
21+
22+
23+
.PHONY: watch up build playwright generate-client

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ services:
167167
context: ./next
168168
args:
169169
- VITE_API_URL=https://api.${DOMAIN?Variable not set}
170+
- AUTH_SECRET=${NEXT_AUTH_SECRET?Variable not set}
170171
- NODE_ENV=production
171172
ports:
172173
- "3000:3000"

frontend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ But it would be only to clean them up, leaving them won't really have any effect
8080
* From the top level project directory, run the script:
8181

8282
```bash
83-
./scripts/generate-frontend-client.sh
83+
make generate-client
8484
```
8585

8686
* Commit the changes.

next/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ yarn-error.log*
3939
# typescript
4040
*.tsbuildinfo
4141
next-env.d.ts
42+
43+
# OpenAPI client
44+
openapi.json
45+
openapi-ts-error-*.log

next/openapi-ts.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { defineConfig } from "@hey-api/openapi-ts"
2+
3+
export default defineConfig({
4+
client: "legacy/axios",
5+
input: "./openapi.json",
6+
output: "./src/client",
7+
// exportSchemas: true,
8+
plugins: [
9+
{
10+
name: "@hey-api/sdk",
11+
// NOTE: this doesn't allow tree-shaking
12+
asClass: true,
13+
operationId: true,
14+
methodNameBuilder: (operation) => {
15+
// @ts-ignore
16+
let name: string = operation.name
17+
// @ts-ignore
18+
let service: string = operation.service
19+
20+
if (service && name.toLowerCase().startsWith(service.toLowerCase())) {
21+
name = name.slice(service.length)
22+
}
23+
24+
return name.charAt(0).toLowerCase() + name.slice(1)
25+
},
26+
},
27+
],
28+
})

0 commit comments

Comments
 (0)