-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b454256
commit ba07654
Showing
65 changed files
with
8,845 additions
and
9,143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2020: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/recommended', | ||
'plugin:import/typescript', | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:tailwindcss/recommended', | ||
], | ||
overrides: [ | ||
{ | ||
env: { | ||
node: true, | ||
}, | ||
files: ['.eslintrc.{js,cjs}'], | ||
parserOptions: { | ||
sourceType: 'script', | ||
}, | ||
}, | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint', 'react'], | ||
rules: { | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ | ||
argsIgnorePattern: '^_', | ||
destructuredArrayIgnorePattern: '^_', | ||
varsIgnorePattern: '^_', | ||
}, | ||
], | ||
'linebreak-style': ['error', 'unix'], | ||
'no-constant-condition': ['error', { checkLoops: false }], | ||
quotes: ['error', 'single', { avoidEscape: true }], | ||
semi: ['error', 'always'], | ||
'@typescript-eslint/consistent-type-imports': 'error', | ||
'no-param-reassign': 'error', | ||
'no-var': 'error', | ||
'prefer-const': 'error', | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.cjs', '.d.ts', '.js', '.jsx', '.mjs', '.ts', '.tsx'], | ||
}, | ||
}, | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Petstore</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Petstore</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { z } from 'zod'; | ||
|
||
export const numberSchema = z.union([ | ||
z | ||
.string() | ||
.refine((number) => !Number.isNaN(parseInt(number, 10))) | ||
.transform((number) => parseInt(number, 10)), | ||
z.number(), | ||
]); | ||
|
||
export const sortSchema = z.union([z.literal('asc'), z.literal('desc')]); | ||
|
||
const linkSchema = z.object({ | ||
href: z.string(), | ||
}); | ||
|
||
export const modelRequestSchema = z.object({}).strict(); | ||
|
||
export type ModelRequest = z.infer<typeof modelRequestSchema>; | ||
|
||
export const modelResponseSchema = z | ||
.object({ | ||
id: z.string(), | ||
createdAt: z.string(), | ||
updatedAt: z.string().nullish(), | ||
_links: z | ||
.object({ | ||
read: linkSchema.nullish(), | ||
update: linkSchema.nullish(), | ||
delete: linkSchema.nullish(), | ||
}) | ||
.strict(), | ||
}) | ||
.strict(); | ||
|
||
export type ModelResponse = z.infer<typeof modelResponseSchema>; | ||
|
||
export const modelListRequestSchema = z | ||
.object({ | ||
offset: numberSchema.optional(), | ||
limit: numberSchema.optional(), | ||
filters: z.object({}).strict().optional(), | ||
sort: z.object({}).strict().optional(), | ||
}) | ||
.strict(); | ||
|
||
export type ModelListRequest = z.infer<typeof modelListRequestSchema>; | ||
|
||
export const modelListResponseSchema = z | ||
.object({ | ||
offset: numberSchema, | ||
limit: numberSchema, | ||
filters: z.object({}).strict(), | ||
sort: z.object({}).strict(), | ||
count: numberSchema, | ||
items: z.array(modelResponseSchema), | ||
_links: z.object({ | ||
create: linkSchema.nullish(), | ||
}), | ||
}) | ||
.strict(); | ||
|
||
export type ModelListResponse = z.infer<typeof modelListResponseSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { z } from 'zod'; | ||
import { | ||
modelRequestSchema, | ||
modelResponseSchema, | ||
modelListRequestSchema, | ||
sortSchema, | ||
modelListResponseSchema, | ||
} from './model'; | ||
|
||
export const petRequestSchema = z.object({ | ||
...modelRequestSchema.shape, | ||
name: z.string(), | ||
tag: z.string().nullish(), | ||
vaccinations: z.array( | ||
z.object({ | ||
name: z.string(), | ||
}), | ||
), | ||
}); | ||
|
||
export type PetRequest = z.infer<typeof petRequestSchema>; | ||
|
||
export const petResponseSchema = z.object({ | ||
...modelResponseSchema.shape, | ||
...petRequestSchema.shape, | ||
}); | ||
|
||
export type PetResponse = z.infer<typeof petResponseSchema>; | ||
|
||
export const petFiltersSchema = z.object({ | ||
name: z.string().nullish(), | ||
}); | ||
|
||
export type PetFilters = z.infer<typeof petFiltersSchema>; | ||
|
||
export const petSortSchema = z.object({ | ||
name: sortSchema.nullish(), | ||
}); | ||
|
||
export type PetSort = z.infer<typeof petSortSchema>; | ||
|
||
export const petListRequestSchema = z.object({ | ||
...modelListRequestSchema.shape, | ||
filters: petFiltersSchema.optional(), | ||
sort: petSortSchema.optional(), | ||
}); | ||
|
||
export type PetListRequest = z.infer<typeof petListRequestSchema>; | ||
|
||
export const petListResponseSchema = z.object({ | ||
...modelListResponseSchema.shape, | ||
filters: petFiltersSchema, | ||
sort: petSortSchema, | ||
items: z.array(petResponseSchema), | ||
}); | ||
|
||
export type PetListResponse = z.infer<typeof petListResponseSchema>; |
Oops, something went wrong.