Skip to content

Commit 82eab42

Browse files
committed
Implement test
1 parent 817e79f commit 82eab42

35 files changed

+493
-336
lines changed

bun.lock

Lines changed: 100 additions & 4 deletions
Large diffs are not rendered by default.

examples/next-webpack/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ yarn-error.log*
3535
next-env.d.ts
3636

3737
# devup-api
38-
.devup-api
38+
df
3939

examples/next-webpack/app/globals.css

Lines changed: 0 additions & 35 deletions
This file was deleted.

examples/next-webpack/app/layout.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { Metadata } from 'next'
2-
import './globals.css'
32

43
export const metadata: Metadata = {
5-
title: 'Next.js Webpack Example - devup-api',
6-
description: 'Example Next.js app with devup-api plugin (Webpack)',
4+
title: 'Next.js Example - devup-api',
5+
description: 'Example Next.js app with devup-api plugin',
76
}
87

98
export default function RootLayout({

examples/next-webpack/app/page.tsx

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,58 @@
11
'use client'
22

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+
39
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+
}, [])
434
return (
5-
<main className="flex min-h-screen flex-col items-center justify-center p-24">
6-
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm">
7-
<h1 className="text-4xl font-bold mb-8">Next.js Example (Webpack)</h1>
8-
<p className="mb-4">
9-
This example uses Next.js with Webpack and devup-api plugin.
10-
</p>
11-
<div className="mt-8 p-4 bg-gray-100 rounded">
12-
<p className="font-semibold mb-2">Environment Variables:</p>
13-
<pre className="text-xs overflow-auto">
14-
{(() => {
15-
try {
16-
const urlMap = process.env.DEVUP_API_URL_MAP
17-
if (!urlMap) return 'Not available'
18-
const parsed =
19-
typeof urlMap === 'string' ? JSON.parse(urlMap) : urlMap
20-
return JSON.stringify(parsed, null, 2)
21-
} catch {
22-
return 'Error parsing URL map'
23-
}
24-
})()}
25-
</pre>
26-
</div>
27-
</div>
28-
</main>
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>
2957
)
3058
}
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import devupApi from '@devup-api/next-plugin'
2+
import { DevupUI } from '@devup-ui/next-plugin'
23

3-
const config = devupApi(
4-
{
5-
reactStrictMode: true,
6-
},
7-
{
8-
openapiFile: './openapi.json',
9-
tempDir: '.devup-api',
10-
},
11-
)
4+
const config = devupApi({
5+
reactStrictMode: true,
6+
})
127

13-
export default config
8+
export default DevupUI(config)

examples/next-webpack/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev",
6+
"dev": "next dev --webpack",
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint"
@@ -13,9 +13,11 @@
1313
"react": "^19.2.0",
1414
"react-dom": "^19.2.0",
1515
"@devup-api/next-plugin": "workspace:*",
16-
"@devup-api/core": "workspace:*"
16+
"@devup-api/fetch": "workspace:*",
17+
"@devup-ui/react": "^1"
1718
},
1819
"devDependencies": {
20+
"@devup-ui/next-plugin": "^1",
1921
"@types/node": "^24",
2022
"@types/react": "^19",
2123
"@types/react-dom": "^19",

examples/next-webpack/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"**/*.ts",
2828
"**/*.tsx",
2929
".next/types/**/*.ts",
30-
".next/dev/types/**/*.ts"
30+
".next/dev/types/**/*.ts",
31+
"df/**/*.d.ts"
3132
],
3233
"exclude": ["node_modules"]
3334
}

examples/next/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ yarn-error.log*
3535
next-env.d.ts
3636

3737
# devup-api
38-
.devup-api
38+
df
3939

examples/next/app/globals.css

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)