Skip to content

Commit b19272f

Browse files
committed
Rev examples
1 parent c9e827a commit b19272f

32 files changed

+1329
-0
lines changed

examples/next-webpack/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env*.local
29+
30+
# vercel
31+
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
next-env.d.ts
36+
37+
# devup-api
38+
df
39+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Metadata } from 'next'
2+
3+
export const metadata: Metadata = {
4+
title: 'Next.js Example - devup-api',
5+
description: 'Example Next.js app with devup-api plugin',
6+
}
7+
8+
export default function RootLayout({
9+
children,
10+
}: {
11+
children: React.ReactNode
12+
}) {
13+
return (
14+
<html lang="en">
15+
<body>{children}</body>
16+
</html>
17+
)
18+
}

examples/next-webpack/app/page.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use client'
2+
3+
import { createApi } from '@devup-api/fetch'
4+
import { Box, Text } from '@devup-ui/react'
5+
import { useEffect } from 'react'
6+
7+
const api = createApi('https://api.example.com')
8+
9+
export default function Home() {
10+
useEffect(() => {
11+
api.get('getUsers', {}).then((res) => {
12+
console.log(res)
13+
})
14+
15+
api
16+
.get('getUserById', {
17+
params: { id: 1 },
18+
})
19+
.then((res) => {
20+
console.log(res)
21+
})
22+
23+
api
24+
.post('createUser', {
25+
body: {
26+
name: 'John Doe',
27+
28+
},
29+
})
30+
.then((res) => {
31+
console.log(res)
32+
})
33+
}, [])
34+
return (
35+
<Box>
36+
<Text>Next.js Example (Turbopack)</Text>
37+
<Box>
38+
<Box>
39+
<Box>
40+
<Box>
41+
{(() => {
42+
try {
43+
const urlMap = process.env.DEVUP_API_URL_MAP
44+
if (!urlMap) return 'Not available'
45+
const parsed =
46+
typeof urlMap === 'string' ? JSON.parse(urlMap) : urlMap
47+
return JSON.stringify(parsed, null, 2)
48+
} catch {
49+
return 'Error parsing URL map'
50+
}
51+
})()}
52+
</Box>
53+
</Box>
54+
</Box>
55+
</Box>
56+
</Box>
57+
)
58+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import devupApi from '@devup-api/next-plugin'
2+
import { DevupUI } from '@devup-ui/next-plugin'
3+
4+
const config = devupApi({
5+
reactStrictMode: true,
6+
})
7+
8+
export default DevupUI(config)

examples/next-webpack/openapi.json

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Example API",
5+
"version": "1.0.0",
6+
"description": "Example OpenAPI specification for testing devup-api"
7+
},
8+
"paths": {
9+
"/users": {
10+
"get": {
11+
"summary": "Get all users",
12+
"operationId": "getUsers",
13+
"responses": {
14+
"200": {
15+
"description": "List of users",
16+
"content": {
17+
"application/json": {
18+
"schema": {
19+
"type": "array",
20+
"items": {
21+
"$ref": "#/components/schemas/User"
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}
28+
},
29+
"post": {
30+
"summary": "Create a new user",
31+
"operationId": "createUser",
32+
"requestBody": {
33+
"required": true,
34+
"content": {
35+
"application/json": {
36+
"schema": {
37+
"$ref": "#/components/schemas/CreateUserRequest"
38+
}
39+
}
40+
}
41+
},
42+
"responses": {
43+
"201": {
44+
"description": "User created",
45+
"content": {
46+
"application/json": {
47+
"schema": {
48+
"$ref": "#/components/schemas/User"
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}
55+
},
56+
"/users/{id}": {
57+
"get": {
58+
"summary": "Get user by ID",
59+
"operationId": "getUserById",
60+
"parameters": [
61+
{
62+
"name": "id",
63+
"in": "path",
64+
"required": true,
65+
"schema": {
66+
"type": "integer"
67+
}
68+
}
69+
],
70+
"responses": {
71+
"200": {
72+
"description": "User details",
73+
"content": {
74+
"application/json": {
75+
"schema": {
76+
"$ref": "#/components/schemas/User"
77+
}
78+
}
79+
}
80+
}
81+
}
82+
}
83+
}
84+
},
85+
"components": {
86+
"schemas": {
87+
"User": {
88+
"type": "object",
89+
"properties": {
90+
"id": {
91+
"type": "integer"
92+
},
93+
"name": {
94+
"type": "string"
95+
},
96+
"email": {
97+
"type": "string",
98+
"format": "email"
99+
},
100+
"createdAt": {
101+
"type": "string",
102+
"format": "date-time"
103+
}
104+
},
105+
"required": ["id", "name", "email"]
106+
},
107+
"CreateUserRequest": {
108+
"type": "object",
109+
"properties": {
110+
"name": {
111+
"type": "string"
112+
},
113+
"email": {
114+
"type": "string",
115+
"format": "email"
116+
}
117+
},
118+
"required": ["name", "email"]
119+
}
120+
}
121+
}
122+
}

examples/next-webpack/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "next-webpack-example",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev --webpack",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"next": "^16.0.4",
13+
"react": "^19.2.0",
14+
"react-dom": "^19.2.0",
15+
"@devup-api/next-plugin": "workspace:*",
16+
"@devup-api/fetch": "workspace:*",
17+
"@devup-ui/react": "^1"
18+
},
19+
"devDependencies": {
20+
"@devup-ui/next-plugin": "^1",
21+
"@types/node": "^24",
22+
"@types/react": "^19",
23+
"@types/react-dom": "^19",
24+
"typescript": "^5"
25+
}
26+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2017",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"noEmit": true,
9+
"esModuleInterop": true,
10+
"module": "esnext",
11+
"moduleResolution": "bundler",
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"jsx": "react-jsx",
15+
"incremental": true,
16+
"plugins": [
17+
{
18+
"name": "next"
19+
}
20+
],
21+
"paths": {
22+
"@/*": ["./*"]
23+
}
24+
},
25+
"include": [
26+
"next-env.d.ts",
27+
"**/*.ts",
28+
"**/*.tsx",
29+
".next/types/**/*.ts",
30+
".next/dev/types/**/*.ts",
31+
"df/**/*.d.ts"
32+
],
33+
"exclude": ["node_modules"]
34+
}

examples/next/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env*.local
29+
30+
# vercel
31+
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
next-env.d.ts
36+
37+
# devup-api
38+
df
39+

examples/next/app/layout.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Metadata } from 'next'
2+
3+
export const metadata: Metadata = {
4+
title: 'Next.js Example - devup-api',
5+
description: 'Example Next.js app with devup-api plugin',
6+
}
7+
8+
export default function RootLayout({
9+
children,
10+
}: {
11+
children: React.ReactNode
12+
}) {
13+
return (
14+
<html lang="en">
15+
<body>{children}</body>
16+
</html>
17+
)
18+
}

0 commit comments

Comments
 (0)