Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/gen schema #48

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_BACKEND_URL=
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// language - current active spelling language
"language": "en",
// words - list of words to be always considered correct
"words": ["autodocs"],
"words": ["aspida", "autodocs", "clsx"],
"ignorePaths": ["src/api/**/*"]
// flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors.
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"new:page": "hygen generator page",
"prepare": "husky install",
"commitmsg": "commitlint -e $GIT_PARAMS",
"mock": "prism mock ./schema/build/openapi.yml",
"type": "openapi2aspida -c ./aspida.config.js --dotenv .env.local",
"fmt": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,scss}'",
"check:lint": "eslint 'src/**/*.{ts,tsx}' --report-unused-disable-directives --max-warnings 0",
Expand All @@ -36,6 +37,7 @@
]
},
"dependencies": {
"@aspida/fetch": "^1.14.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-popover": "^1.0.7",
Expand All @@ -44,10 +46,15 @@
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@stoplight/prism-cli": "^5.5.0",
"@tanstack/react-query": "^5.0.5",
"aspida": "^1.14.0",
"date-fns": "^2.30.0",
"lucide-react": "^0.288.0",
"next": "13.5.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-boundary": "^4.0.11",
"react-icons": "^4.11.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion schema
Submodule schema updated 3 files
+250 −17 build/openapi.yml
+17 −0 docs/CHANGELOG.md
+836 −627 spec/openapi.yml
61 changes: 39 additions & 22 deletions src/api/$api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AspidaClient, BasicHeaders } from 'aspida';
import type { Methods as Methods_1vmdska } from './accounts/_id@string';
import type { Methods as Methods_17l7lnu } from './accounts/register';
import type { Methods as Methods_1nkw4za } from './accounts/register/password';
import type { Methods as Methods_66bvhy } from './accounts/update';
import type { Methods as Methods_12twjkf } from './follows/create/_id@string';
import type { Methods as Methods_1ot5dgu } from './follows/delete/_id@string';
Expand All @@ -14,14 +15,15 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, '');
const PATH0 = '/accounts';
const PATH1 = '/accounts/register';
const PATH2 = '/accounts/update';
const PATH3 = '/follows/create';
const PATH4 = '/follows/delete';
const PATH5 = '/likes/create';
const PATH6 = '/likes/delete';
const PATH7 = '/tweets/delete';
const PATH8 = '/tweets/get/timeline';
const PATH9 = '/tweets/post';
const PATH2 = '/accounts/register/password';
const PATH3 = '/accounts/update';
const PATH4 = '/follows/create';
const PATH5 = '/follows/delete';
const PATH6 = '/likes/create';
const PATH7 = '/likes/delete';
const PATH8 = '/tweets/delete';
const PATH9 = '/tweets/get/timeline';
const PATH10 = '/tweets/post';
const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
Expand All @@ -47,6 +49,21 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
};
},
register: {
password: {
/**
* @param option.body - password to create
* @returns success
*/
post: (option: { body: Methods_1nkw4za['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods_1nkw4za['post']['resBody'], BasicHeaders, Methods_1nkw4za['post']['status']>(prefix, PATH2, POST, option).json(),
/**
* @param option.body - password to create
* @returns success
*/
$post: (option: { body: Methods_1nkw4za['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods_1nkw4za['post']['resBody'], BasicHeaders, Methods_1nkw4za['post']['status']>(prefix, PATH2, POST, option).json().then(r => r.body),
$path: () => `${prefix}${PATH2}`,
},
/**
* @param option.body - account to create
* @returns success
Expand All @@ -67,20 +84,20 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @returns success
*/
put: (option: { body: Methods_66bvhy['put']['reqBody'], config?: T | undefined }) =>
fetch<Methods_66bvhy['put']['resBody'], BasicHeaders, Methods_66bvhy['put']['status']>(prefix, PATH2, PUT, option).json(),
fetch<Methods_66bvhy['put']['resBody'], BasicHeaders, Methods_66bvhy['put']['status']>(prefix, PATH3, PUT, option).json(),
/**
* @param option.body - account to update
* @returns success
*/
$put: (option: { body: Methods_66bvhy['put']['reqBody'], config?: T | undefined }) =>
fetch<Methods_66bvhy['put']['resBody'], BasicHeaders, Methods_66bvhy['put']['status']>(prefix, PATH2, PUT, option).json().then(r => r.body),
$path: () => `${prefix}${PATH2}`,
fetch<Methods_66bvhy['put']['resBody'], BasicHeaders, Methods_66bvhy['put']['status']>(prefix, PATH3, PUT, option).json().then(r => r.body),
$path: () => `${prefix}${PATH3}`,
},
},
follows: {
create: {
_id: (val2: string) => {
const prefix2 = `${PATH3}/${val2}`;
const prefix2 = `${PATH4}/${val2}`;

return {
/**
Expand All @@ -99,7 +116,7 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
},
delete: {
_id: (val2: string) => {
const prefix2 = `${PATH4}/${val2}`;
const prefix2 = `${PATH5}/${val2}`;

return {
/**
Expand All @@ -120,7 +137,7 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
likes: {
create: {
_id: (val2: string) => {
const prefix2 = `${PATH5}/${val2}`;
const prefix2 = `${PATH6}/${val2}`;

return {
/**
Expand All @@ -139,7 +156,7 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
},
delete: {
_id: (val2: string) => {
const prefix2 = `${PATH6}/${val2}`;
const prefix2 = `${PATH7}/${val2}`;

return {
/**
Expand All @@ -160,7 +177,7 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
tweets: {
delete: {
_id: (val2: string) => {
const prefix2 = `${PATH7}/${val2}`;
const prefix2 = `${PATH8}/${val2}`;

return {
/**
Expand All @@ -183,13 +200,13 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @returns success
*/
get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods_um4wq7['get']['resBody'], BasicHeaders, Methods_um4wq7['get']['status']>(prefix, PATH8, GET, option).json(),
fetch<Methods_um4wq7['get']['resBody'], BasicHeaders, Methods_um4wq7['get']['status']>(prefix, PATH9, GET, option).json(),
/**
* @returns success
*/
$get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods_um4wq7['get']['resBody'], BasicHeaders, Methods_um4wq7['get']['status']>(prefix, PATH8, GET, option).json().then(r => r.body),
$path: () => `${prefix}${PATH8}`,
fetch<Methods_um4wq7['get']['resBody'], BasicHeaders, Methods_um4wq7['get']['status']>(prefix, PATH9, GET, option).json().then(r => r.body),
$path: () => `${prefix}${PATH9}`,
},
},
post: {
Expand All @@ -198,14 +215,14 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @returns success
*/
post: (option: { body: Methods_hsfp97['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods_hsfp97['post']['resBody'], BasicHeaders, Methods_hsfp97['post']['status']>(prefix, PATH9, POST, option).json(),
fetch<Methods_hsfp97['post']['resBody'], BasicHeaders, Methods_hsfp97['post']['status']>(prefix, PATH10, POST, option).json(),
/**
* @param option.body - tweet to delete
* @returns success
*/
$post: (option: { body: Methods_hsfp97['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods_hsfp97['post']['resBody'], BasicHeaders, Methods_hsfp97['post']['status']>(prefix, PATH9, POST, option).json().then(r => r.body),
$path: () => `${prefix}${PATH9}`,
fetch<Methods_hsfp97['post']['resBody'], BasicHeaders, Methods_hsfp97['post']['status']>(prefix, PATH10, POST, option).json().then(r => r.body),
$path: () => `${prefix}${PATH10}`,
},
},
};
Expand Down
120 changes: 84 additions & 36 deletions src/api/@types/index.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,115 @@
/* eslint-disable */
export type OkResponse = {
message?: string | undefined
message: string
}

export type ErrorResponse = {
message?: string | undefined
message: string
}

export type RegisterAccountPayload = {
id: string
name: string
tel_num: string
birth_day: string
}

export type RegisterPasswordPayload = {
id: string
password: string
}

export type UpdateAccountPayload = {
name?: string | undefined
description?: string | undefined
image_url?: string | undefined
birth_day?: string | undefined
website_url?: string | undefined
name: string
description: string
image_url: string
birth_day: string
website_url: string
}

export type Account = {
id?: string | undefined
name?: string | undefined
description?: string | undefined
image_url?: string | undefined
birth_day?: string | undefined
website_url?: string | undefined
id: string
name: string
description: string
image_url: string
birth_day: string
website_url: string
follow_count: number
follower_count: number
is_following: boolean
role: number
}

export type CreateTweetPayload = {
content?: string | undefined
image_url_list?: string[] | undefined
account_id?: string | undefined
reply_to?: string | undefined
root?: string | undefined
content: string
image_url_list: string[]
account_id: string
reply_to: string
root: string
}

export type CreateTweetResponse = {
id?: string | undefined
content?: string | undefined
image_url_list?: string[] | undefined
created_at?: string | undefined
account_id?: string | undefined
reply_to?: string | undefined
root?: string | undefined
id: string
content: string
image_url_list: string[]
created_at: string
account_id: string
reply_to: string
root: string
}

export type TweetItem = {
id?: string | undefined
content?: string | undefined
image_url_list?: string[] | undefined
created_at?: string | undefined
account_id?: string | undefined
reply_to?: string | undefined
root?: string | undefined
id: string
content: string
image_url_list: string[]
created_at: string
is_favorite: boolean
is_retweet: boolean
impression_count: number
favorite_count: number
retweet_count: number
reply_count: number
is_bookmark: boolean

account: {
id: string
name: string
image_url: string
role: number
}

reply_to: string
root: string

retweet_content: {
id: string
content: string
image_url_list: string[]
created_at: string
is_favorite: boolean
is_retweet: boolean
impression_count: number
favorite_count: number
retweet_count: number
reply_count: number
is_bookmark: boolean

account: {
id: string
name: string
image_url: string
role: number
}

reply_to: string
root: string
} | null
}

export type GetTweetResponse = {
timeline?: TweetItem[] | undefined
timeline: TweetItem[]
}

export type Like = {
account_id?: string | undefined
tweet_id?: string | undefined
account_id: string
tweet_id: string
}
Loading