Skip to content

Commit

Permalink
chore: add a sample app that uses the fetch client with NextJS (o…
Browse files Browse the repository at this point in the history
…rval-labs#1407)

* chore: add a sample app that uses `fetch` client on `Next.js`

* chore: add `generate-api` to `package.json`

* chore: add `msw` to dev deps

* chore: add `OpenaAPI` schema and `orval` config and execute `orval`

* chore: define `baseUrl` to `orval` config

* chore: use generate function in server actions

* chore: rename sample app name

* docs: add link of sample app to each `README`

* chore: remove old sample app

* chore: regenerated functions

* chore: follow `yarn v4`

* chore: regenerate schema files by `orval`

* chore: yarn install

* fix: remove duplicated link in `README`
  • Loading branch information
soartec-lab authored Jun 11, 2024
1 parent 759ef48 commit 8efb741
Show file tree
Hide file tree
Showing 47 changed files with 6,499 additions and 24 deletions.
1 change: 1 addition & 0 deletions packages/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/axios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/fetch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ You can find below some samples
- [nx fastify react](https://github.com/anymaniax/orval/tree/master/samples/nx-fastify-react)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/hono/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/mock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/orval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/swr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
1 change: 1 addition & 0 deletions packages/zod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ You can find below some samples
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
- [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
3 changes: 3 additions & 0 deletions samples/next-app-with-fetch/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions samples/next-app-with-fetch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions samples/next-app-with-fetch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Binary file added samples/next-app-with-fetch/app/favicon.ico
Binary file not shown.
12 changes: 12 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/cat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/
import type { CatType } from './catType';

export interface Cat {
readonly petsRequested?: number;
type: CatType;
}
13 changes: 13 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/catType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type CatType = (typeof CatType)[keyof typeof CatType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CatType = {
cat: 'cat',
} as const;
11 changes: 11 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/createPetsBodyItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type CreatePetsBodyItem = {
name: string;
tag: string;
};
12 changes: 12 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/dachshund.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/
import type { DachshundBreed } from './dachshundBreed';

export interface Dachshund {
breed: DachshundBreed;
length: number;
}
14 changes: 14 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/dachshundBreed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type DachshundBreed =
(typeof DachshundBreed)[keyof typeof DachshundBreed];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const DachshundBreed = {
Dachshund: 'Dachshund',
} as const;
19 changes: 19 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/dog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/
import type { Labradoodle } from './labradoodle';
import type { Dachshund } from './dachshund';
import type { DogType } from './dogType';

export type Dog =
| (Labradoodle & {
barksPerMinute?: number;
type: DogType;
})
| (Dachshund & {
barksPerMinute?: number;
type: DogType;
});
13 changes: 13 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/dogType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type DogType = (typeof DogType)[keyof typeof DogType];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const DogType = {
dog: 'dog',
} as const;
11 changes: 11 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export interface Error {
code: number;
message: string;
}
22 changes: 22 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export * from './cat';
export * from './catType';
export * from './createPetsBodyItem';
export * from './dachshund';
export * from './dachshundBreed';
export * from './dog';
export * from './dogType';
export * from './error';
export * from './labradoodle';
export * from './labradoodleBreed';
export * from './listPetsParams';
export * from './pet';
export * from './petCallingCode';
export * from './petCountry';
export * from './pets';
12 changes: 12 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/labradoodle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/
import type { LabradoodleBreed } from './labradoodleBreed';

export interface Labradoodle {
breed: LabradoodleBreed;
cuteness: number;
}
14 changes: 14 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/labradoodleBreed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type LabradoodleBreed =
(typeof LabradoodleBreed)[keyof typeof LabradoodleBreed];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const LabradoodleBreed = {
Labradoodle: 'Labradoodle',
} as const;
13 changes: 13 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/listPetsParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type ListPetsParams = {
/**
* How many items to return at one time (max 100)
*/
limit?: string;
};
30 changes: 30 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/pet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/
import type { Dog } from './dog';
import type { Cat } from './cat';
import type { PetCallingCode } from './petCallingCode';
import type { PetCountry } from './petCountry';

export type Pet =
| (Dog & {
'@id'?: string;
callingCode?: PetCallingCode;
country?: PetCountry;
email?: string;
id: number;
name: string;
tag?: string;
})
| (Cat & {
'@id'?: string;
callingCode?: PetCallingCode;
country?: PetCountry;
email?: string;
id: number;
name: string;
tag?: string;
});
15 changes: 15 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/petCallingCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type PetCallingCode =
(typeof PetCallingCode)[keyof typeof PetCallingCode];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PetCallingCode = {
'+33': '+33',
'+420': '+420',
} as const;
14 changes: 14 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/petCountry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/

export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PetCountry = {
"People's_Republic_of_China": "People's Republic of China",
Uruguay: 'Uruguay',
} as const;
9 changes: 9 additions & 0 deletions samples/next-app-with-fetch/app/gen/models/pets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Generated by orval v6.29.1 🍺
* Do not edit manually.
* Swagger Petstore
* OpenAPI spec version: 1.0.0
*/
import type { Pet } from './pet';

export type Pets = Pet[];
Loading

0 comments on commit 8efb741

Please sign in to comment.