diff --git a/.eslintignore b/.eslintignore index 89aa27a..3d0b276 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,4 +12,5 @@ build/ _templates/ setup.js -*.config.* \ No newline at end of file +*.config.* +src/apis \ No newline at end of file diff --git a/aspida.config.js b/aspida.config.js new file mode 100644 index 0000000..d7e42c3 --- /dev/null +++ b/aspida.config.js @@ -0,0 +1,5 @@ +module.exports = { + input: 'src/apis/', // "input" of aspida is "output" for openapi2aspida + outputEachDir: true, // Generate $api.ts in each endpoint directory + openapi: { inputFile: './schemas/build/openapi.yml' }, +}; diff --git a/bun.lockb b/bun.lockb index 32096ea..95dff52 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/cspell.config.json b/cspell.config.json index 978ff57..a401aa1 100644 --- a/cspell.config.json +++ b/cspell.config.json @@ -6,7 +6,7 @@ "language": "en", // words - list of words to be always considered correct "words": ["autodocs"], - "ignorePaths": [] + "ignorePaths": ["./src/apis"] // flagWords - list of words to be always considered incorrect // This is useful for offensive words and common spelling errors. // For example "hte" should be "the" diff --git a/package.json b/package.json index c2132c5..0d0c232 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "new:model": "hygen generator model", "new:page": "hygen generator page", "prepare": "husky install", + "generate:type": "rm -r src/apis && openapi2aspida -c ./aspida.config.js", "commitmsg": "commitlint -e $GIT_PARAMS", "fmt": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,scss}'", "check:lint": "eslint 'src/**/*.{ts,tsx}' --report-unused-disable-directives --max-warnings 0", @@ -43,6 +44,10 @@ "devDependencies": { "@commitlint/cli": "^17.7.1", "@commitlint/config-conventional": "^17.7.0", + "@fortawesome/fontawesome-free": "^6.4.2", + "@fortawesome/fontawesome-svg-core": "^6.4.2", + "@fortawesome/free-solid-svg-icons": "^6.4.2", + "@fortawesome/react-fontawesome": "^0.2.0", "@markuplint/jsx-parser": "^3.9.1", "@markuplint/react-spec": "^3.10.1", "@storybook/addon-essentials": "^7.2.2", @@ -59,8 +64,8 @@ "@tsconfig/strictest": "^2.0.1", "@types/jest": "^29.5.4", "@types/node": "20.8.4", - "@types/react-dom": "18.2.13", "@types/react": "18.2.28", + "@types/react-dom": "18.2.13", "@typescript-eslint/eslint-plugin": "^6.3.0", "@typescript-eslint/parser": "^6.3.0", "autoprefixer": "^10.4.16", @@ -80,16 +85,13 @@ "lint-staged": "^14.0.1", "markuplint": "^3.12.1", "npm-run-all": "^4.1.5", + "openapi2aspida": "^0.23.2", "postcss": "^8.4.31", "prettier": "^3.0.1", "storybook": "^7.2.2", "tailwindcss": "^3.3.3", "ts-jest": "^29.1.1", - "typescript": "5.2.2", - "@fortawesome/fontawesome-free": "^6.4.2", - "@fortawesome/fontawesome-svg-core": "^6.4.2", - "@fortawesome/free-solid-svg-icons": "^6.4.2", - "@fortawesome/react-fontawesome": "^0.2.0" + "typescript": "5.2.2" }, "volta": { "node": "20.6.1", diff --git a/src/apis/$api.ts b/src/apis/$api.ts new file mode 100644 index 0000000..ea88a46 --- /dev/null +++ b/src/apis/$api.ts @@ -0,0 +1,215 @@ +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_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'; +import type { Methods as Methods_hm9c1h } from './likes/create/_id@string'; +import type { Methods as Methods_oom3sk } from './likes/delete/_id@string'; +import type { Methods as Methods_ubgeda } from './tweets/delete/_id@string'; +import type { Methods as Methods_um4wq7 } from './tweets/get/timeline'; +import type { Methods as Methods_hsfp97 } from './tweets/post'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + 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 GET = 'GET'; + const POST = 'POST'; + const PUT = 'PUT'; + const DELETE = 'DELETE'; + + return { + accounts: { + _id: (val1: string) => { + const prefix1 = `${PATH0}/${val1}`; + + return { + /** + * @returns success + */ + get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, GET, option).json(), + /** + * @returns success + */ + $get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, GET, option).json().then(r => r.body), + $path: () => `${prefix}${prefix1}`, + }; + }, + register: { + /** + * @param option.body - account to create + * @returns success + */ + post: (option: { body: Methods_17l7lnu['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH1, POST, option).json(), + /** + * @param option.body - account to create + * @returns success + */ + $post: (option: { body: Methods_17l7lnu['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH1, POST, option).json().then(r => r.body), + $path: () => `${prefix}${PATH1}`, + }, + update: { + /** + * @param option.body - account to update + * @returns success + */ + put: (option: { body: Methods_66bvhy['put']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH2, PUT, option).json(), + /** + * @param option.body - account to update + * @returns success + */ + $put: (option: { body: Methods_66bvhy['put']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH2, PUT, option).json().then(r => r.body), + $path: () => `${prefix}${PATH2}`, + }, + }, + follows: { + create: { + _id: (val2: string) => { + const prefix2 = `${PATH3}/${val2}`; + + return { + /** + * @returns success + */ + post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, POST, option).json(), + /** + * @returns success + */ + $post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, POST, option).json().then(r => r.body), + $path: () => `${prefix}${prefix2}`, + }; + }, + }, + delete: { + _id: (val2: string) => { + const prefix2 = `${PATH4}/${val2}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix2}`, + }; + }, + }, + }, + likes: { + create: { + _id: (val2: string) => { + const prefix2 = `${PATH5}/${val2}`; + + return { + /** + * @returns success + */ + post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, POST, option).json(), + /** + * @returns success + */ + $post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, POST, option).json().then(r => r.body), + $path: () => `${prefix}${prefix2}`, + }; + }, + }, + delete: { + _id: (val2: string) => { + const prefix2 = `${PATH6}/${val2}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix2}`, + }; + }, + }, + }, + tweets: { + delete: { + _id: (val2: string) => { + const prefix2 = `${PATH7}/${val2}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix2, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix2}`, + }; + }, + }, + get: { + timeline: { + /** + * @returns success + */ + get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH8, GET, option).json(), + /** + * @returns success + */ + $get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH8, GET, option).json().then(r => r.body), + $path: () => `${prefix}${PATH8}`, + }, + }, + post: { + /** + * @param option.body - tweet to delete + * @returns success + */ + post: (option: { body: Methods_hsfp97['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH9, POST, option).json(), + /** + * @param option.body - tweet to delete + * @returns success + */ + $post: (option: { body: Methods_hsfp97['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH9, POST, option).json().then(r => r.body), + $path: () => `${prefix}${PATH9}`, + }, + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/@types/index.ts b/src/apis/@types/index.ts new file mode 100644 index 0000000..f5584ba --- /dev/null +++ b/src/apis/@types/index.ts @@ -0,0 +1,67 @@ +/* eslint-disable */ +export type OkResponse = { + message?: string | undefined +} + +export type ErrorResponse = { + message?: string | undefined +} + +export type RegisterAccountPayload = { + id: string + name: string +} + +export type UpdateAccountPayload = { + name?: string | undefined + description?: string | undefined + image_url?: string | undefined + birth_day?: string | undefined + website_url?: string | undefined +} + +export type Account = { + id?: string | undefined + name?: string | undefined + description?: string | undefined + image_url?: string | undefined + birth_day?: string | undefined + website_url?: string | undefined +} + +export type CreateTweetPayload = { + content?: string | undefined + image_url_list?: string[] | undefined + account_id?: string | undefined + reply_to?: string | undefined + root?: string | undefined +} + +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 +} + +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 +} + +export type GetTweetResponse = { + timeline?: TweetItem[] | undefined +} + +export type Like = { + account_id?: string | undefined + tweet_id?: string | undefined +} diff --git a/src/apis/accounts/$api.ts b/src/apis/accounts/$api.ts new file mode 100644 index 0000000..ff42276 --- /dev/null +++ b/src/apis/accounts/$api.ts @@ -0,0 +1,67 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_2yw7dz } from './_id@string'; +import type { Methods as Methods_1pbnd9f } from './register'; +import type { Methods as Methods_ut8bpv } from './update'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/accounts'; + const PATH1 = '/accounts/register'; + const PATH2 = '/accounts/update'; + const GET = 'GET'; + const POST = 'POST'; + const PUT = 'PUT'; + + return { + _id: (val0: string) => { + const prefix0 = `${PATH0}/${val0}`; + + return { + /** + * @returns success + */ + get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, GET, option).json(), + /** + * @returns success + */ + $get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, GET, option).json().then(r => r.body), + $path: () => `${prefix}${prefix0}`, + }; + }, + register: { + /** + * @param option.body - account to create + * @returns success + */ + post: (option: { body: Methods_1pbnd9f['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH1, POST, option).json(), + /** + * @param option.body - account to create + * @returns success + */ + $post: (option: { body: Methods_1pbnd9f['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH1, POST, option).json().then(r => r.body), + $path: () => `${prefix}${PATH1}`, + }, + update: { + /** + * @param option.body - account to update + * @returns success + */ + put: (option: { body: Methods_ut8bpv['put']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH2, PUT, option).json(), + /** + * @param option.body - account to update + * @returns success + */ + $put: (option: { body: Methods_ut8bpv['put']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH2, PUT, option).json().then(r => r.body), + $path: () => `${prefix}${PATH2}`, + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/accounts/@me/index.ts b/src/apis/accounts/@me/index.ts new file mode 100644 index 0000000..3f796f1 --- /dev/null +++ b/src/apis/accounts/@me/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../@types' + +export type Methods = { + get: { + status: 200 + /** success */ + resBody: Types.Account + } +} diff --git a/src/apis/accounts/_id@string/index.ts b/src/apis/accounts/_id@string/index.ts new file mode 100644 index 0000000..3f796f1 --- /dev/null +++ b/src/apis/accounts/_id@string/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../@types' + +export type Methods = { + get: { + status: 200 + /** success */ + resBody: Types.Account + } +} diff --git a/src/apis/accounts/register/$api.ts b/src/apis/accounts/register/$api.ts new file mode 100644 index 0000000..fa19f86 --- /dev/null +++ b/src/apis/accounts/register/$api.ts @@ -0,0 +1,27 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_by08hd } from '.'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/accounts/register'; + const POST = 'POST'; + + return { + /** + * @param option.body - account to create + * @returns success + */ + post: (option: { body: Methods_by08hd['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH0, POST, option).json(), + /** + * @param option.body - account to create + * @returns success + */ + $post: (option: { body: Methods_by08hd['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH0, POST, option).json().then(r => r.body), + $path: () => `${prefix}${PATH0}`, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/accounts/register/index.ts b/src/apis/accounts/register/index.ts new file mode 100644 index 0000000..0dddf77 --- /dev/null +++ b/src/apis/accounts/register/index.ts @@ -0,0 +1,12 @@ +/* eslint-disable */ +import type * as Types from '../../@types' + +export type Methods = { + post: { + status: 201 + /** success */ + resBody: Types.OkResponse + /** account to create */ + reqBody: Types.RegisterAccountPayload + } +} diff --git a/src/apis/accounts/update/$api.ts b/src/apis/accounts/update/$api.ts new file mode 100644 index 0000000..7a22067 --- /dev/null +++ b/src/apis/accounts/update/$api.ts @@ -0,0 +1,27 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_by08hd } from '.'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/accounts/update'; + const PUT = 'PUT'; + + return { + /** + * @param option.body - account to update + * @returns success + */ + put: (option: { body: Methods_by08hd['put']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH0, PUT, option).json(), + /** + * @param option.body - account to update + * @returns success + */ + $put: (option: { body: Methods_by08hd['put']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH0, PUT, option).json().then(r => r.body), + $path: () => `${prefix}${PATH0}`, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/accounts/update/index.ts b/src/apis/accounts/update/index.ts new file mode 100644 index 0000000..f8ea990 --- /dev/null +++ b/src/apis/accounts/update/index.ts @@ -0,0 +1,12 @@ +/* eslint-disable */ +import type * as Types from '../../@types' + +export type Methods = { + put: { + status: 200 + /** success */ + resBody: Types.OkResponse + /** account to update */ + reqBody: Types.UpdateAccountPayload + } +} diff --git a/src/apis/follows/$api.ts b/src/apis/follows/$api.ts new file mode 100644 index 0000000..6e6e076 --- /dev/null +++ b/src/apis/follows/$api.ts @@ -0,0 +1,55 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_18j6y1a } from './create/_id@string'; +import type { Methods as Methods_17rt1mb } from './delete/_id@string'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/follows/create'; + const PATH1 = '/follows/delete'; + const POST = 'POST'; + const DELETE = 'DELETE'; + + return { + create: { + _id: (val1: string) => { + const prefix1 = `${PATH0}/${val1}`; + + return { + /** + * @returns success + */ + post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, POST, option).json(), + /** + * @returns success + */ + $post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, POST, option).json().then(r => r.body), + $path: () => `${prefix}${prefix1}`, + }; + }, + }, + delete: { + _id: (val1: string) => { + const prefix1 = `${PATH1}/${val1}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix1}`, + }; + }, + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/follows/create/$api.ts b/src/apis/follows/create/$api.ts new file mode 100644 index 0000000..f271f11 --- /dev/null +++ b/src/apis/follows/create/$api.ts @@ -0,0 +1,31 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_2yw7dz } from './_id@string'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/follows/create'; + const POST = 'POST'; + + return { + _id: (val0: string) => { + const prefix0 = `${PATH0}/${val0}`; + + return { + /** + * @returns success + */ + post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, POST, option).json(), + /** + * @returns success + */ + $post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, POST, option).json().then(r => r.body), + $path: () => `${prefix}${prefix0}`, + }; + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/follows/create/_id@string/index.ts b/src/apis/follows/create/_id@string/index.ts new file mode 100644 index 0000000..2eb888e --- /dev/null +++ b/src/apis/follows/create/_id@string/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../../@types' + +export type Methods = { + post: { + status: 200 + /** success */ + resBody: Types.OkResponse + } +} diff --git a/src/apis/follows/delete/$api.ts b/src/apis/follows/delete/$api.ts new file mode 100644 index 0000000..a5ecd0c --- /dev/null +++ b/src/apis/follows/delete/$api.ts @@ -0,0 +1,31 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_2yw7dz } from './_id@string'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/follows/delete'; + const DELETE = 'DELETE'; + + return { + _id: (val0: string) => { + const prefix0 = `${PATH0}/${val0}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix0}`, + }; + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/follows/delete/_id@string/index.ts b/src/apis/follows/delete/_id@string/index.ts new file mode 100644 index 0000000..5621652 --- /dev/null +++ b/src/apis/follows/delete/_id@string/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../../@types' + +export type Methods = { + delete: { + status: 200 + /** success */ + resBody: Types.OkResponse + } +} diff --git a/src/apis/likes/$api.ts b/src/apis/likes/$api.ts new file mode 100644 index 0000000..ba61d7b --- /dev/null +++ b/src/apis/likes/$api.ts @@ -0,0 +1,55 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_18j6y1a } from './create/_id@string'; +import type { Methods as Methods_17rt1mb } from './delete/_id@string'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/likes/create'; + const PATH1 = '/likes/delete'; + const POST = 'POST'; + const DELETE = 'DELETE'; + + return { + create: { + _id: (val1: string) => { + const prefix1 = `${PATH0}/${val1}`; + + return { + /** + * @returns success + */ + post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, POST, option).json(), + /** + * @returns success + */ + $post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, POST, option).json().then(r => r.body), + $path: () => `${prefix}${prefix1}`, + }; + }, + }, + delete: { + _id: (val1: string) => { + const prefix1 = `${PATH1}/${val1}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix1}`, + }; + }, + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/likes/create/$api.ts b/src/apis/likes/create/$api.ts new file mode 100644 index 0000000..4240b02 --- /dev/null +++ b/src/apis/likes/create/$api.ts @@ -0,0 +1,31 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_2yw7dz } from './_id@string'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/likes/create'; + const POST = 'POST'; + + return { + _id: (val0: string) => { + const prefix0 = `${PATH0}/${val0}`; + + return { + /** + * @returns success + */ + post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, POST, option).json(), + /** + * @returns success + */ + $post: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, POST, option).json().then(r => r.body), + $path: () => `${prefix}${prefix0}`, + }; + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/likes/create/_id@string/index.ts b/src/apis/likes/create/_id@string/index.ts new file mode 100644 index 0000000..0cd8e6d --- /dev/null +++ b/src/apis/likes/create/_id@string/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../../@types' + +export type Methods = { + post: { + status: 200 + /** success */ + resBody: Types.Like + } +} diff --git a/src/apis/likes/delete/$api.ts b/src/apis/likes/delete/$api.ts new file mode 100644 index 0000000..a41e547 --- /dev/null +++ b/src/apis/likes/delete/$api.ts @@ -0,0 +1,31 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_2yw7dz } from './_id@string'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/likes/delete'; + const DELETE = 'DELETE'; + + return { + _id: (val0: string) => { + const prefix0 = `${PATH0}/${val0}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix0}`, + }; + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/likes/delete/_id@string/index.ts b/src/apis/likes/delete/_id@string/index.ts new file mode 100644 index 0000000..5621652 --- /dev/null +++ b/src/apis/likes/delete/_id@string/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../../@types' + +export type Methods = { + delete: { + status: 200 + /** success */ + resBody: Types.OkResponse + } +} diff --git a/src/apis/tweets/$api.ts b/src/apis/tweets/$api.ts new file mode 100644 index 0000000..55e94db --- /dev/null +++ b/src/apis/tweets/$api.ts @@ -0,0 +1,69 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_17rt1mb } from './delete/_id@string'; +import type { Methods as Methods_1qo6b4w } from './get/timeline'; +import type { Methods as Methods_mdeh7w } from './post'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/tweets/delete'; + const PATH1 = '/tweets/get/timeline'; + const PATH2 = '/tweets/post'; + const GET = 'GET'; + const POST = 'POST'; + const DELETE = 'DELETE'; + + return { + delete: { + _id: (val1: string) => { + const prefix1 = `${PATH0}/${val1}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix1, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix1}`, + }; + }, + }, + get: { + timeline: { + /** + * @returns success + */ + get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH1, GET, option).json(), + /** + * @returns success + */ + $get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH1, GET, option).json().then(r => r.body), + $path: () => `${prefix}${PATH1}`, + }, + }, + post: { + /** + * @param option.body - tweet to delete + * @returns success + */ + post: (option: { body: Methods_mdeh7w['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH2, POST, option).json(), + /** + * @param option.body - tweet to delete + * @returns success + */ + $post: (option: { body: Methods_mdeh7w['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH2, POST, option).json().then(r => r.body), + $path: () => `${prefix}${PATH2}`, + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/tweets/delete/$api.ts b/src/apis/tweets/delete/$api.ts new file mode 100644 index 0000000..960a2dc --- /dev/null +++ b/src/apis/tweets/delete/$api.ts @@ -0,0 +1,31 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_2yw7dz } from './_id@string'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/tweets/delete'; + const DELETE = 'DELETE'; + + return { + _id: (val0: string) => { + const prefix0 = `${PATH0}/${val0}`; + + return { + /** + * @returns success + */ + delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, DELETE, option).json(), + /** + * @returns success + */ + $delete: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, prefix0, DELETE, option).json().then(r => r.body), + $path: () => `${prefix}${prefix0}`, + }; + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/tweets/delete/_id@string/index.ts b/src/apis/tweets/delete/_id@string/index.ts new file mode 100644 index 0000000..5621652 --- /dev/null +++ b/src/apis/tweets/delete/_id@string/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../../@types' + +export type Methods = { + delete: { + status: 200 + /** success */ + resBody: Types.OkResponse + } +} diff --git a/src/apis/tweets/get/$api.ts b/src/apis/tweets/get/$api.ts new file mode 100644 index 0000000..dfdf0f4 --- /dev/null +++ b/src/apis/tweets/get/$api.ts @@ -0,0 +1,27 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_1z0uaup } from './timeline'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/tweets/get/timeline'; + const GET = 'GET'; + + return { + timeline: { + /** + * @returns success + */ + get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH0, GET, option).json(), + /** + * @returns success + */ + $get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH0, GET, option).json().then(r => r.body), + $path: () => `${prefix}${PATH0}`, + }, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/tweets/get/timeline/$api.ts b/src/apis/tweets/get/timeline/$api.ts new file mode 100644 index 0000000..52c4ebb --- /dev/null +++ b/src/apis/tweets/get/timeline/$api.ts @@ -0,0 +1,25 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_by08hd } from '.'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/tweets/get/timeline'; + const GET = 'GET'; + + return { + /** + * @returns success + */ + get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH0, GET, option).json(), + /** + * @returns success + */ + $get: (option?: { config?: T | undefined } | undefined) => + fetch(prefix, PATH0, GET, option).json().then(r => r.body), + $path: () => `${prefix}${PATH0}`, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/tweets/get/timeline/index.ts b/src/apis/tweets/get/timeline/index.ts new file mode 100644 index 0000000..3c8ed1a --- /dev/null +++ b/src/apis/tweets/get/timeline/index.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +import type * as Types from '../../../@types' + +export type Methods = { + get: { + status: 200 + /** success */ + resBody: Types.GetTweetResponse + } +} diff --git a/src/apis/tweets/post/$api.ts b/src/apis/tweets/post/$api.ts new file mode 100644 index 0000000..683b2f6 --- /dev/null +++ b/src/apis/tweets/post/$api.ts @@ -0,0 +1,27 @@ +import type { AspidaClient, BasicHeaders } from 'aspida'; +import type { Methods as Methods_by08hd } from '.'; + +const api = ({ baseURL, fetch }: AspidaClient) => { + const prefix = (baseURL === undefined ? 'http://localhost:8000' : baseURL).replace(/\/$/, ''); + const PATH0 = '/tweets/post'; + const POST = 'POST'; + + return { + /** + * @param option.body - tweet to delete + * @returns success + */ + post: (option: { body: Methods_by08hd['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH0, POST, option).json(), + /** + * @param option.body - tweet to delete + * @returns success + */ + $post: (option: { body: Methods_by08hd['post']['reqBody'], config?: T | undefined }) => + fetch(prefix, PATH0, POST, option).json().then(r => r.body), + $path: () => `${prefix}${PATH0}`, + }; +}; + +export type ApiInstance = ReturnType; +export default api; diff --git a/src/apis/tweets/post/index.ts b/src/apis/tweets/post/index.ts new file mode 100644 index 0000000..a53c381 --- /dev/null +++ b/src/apis/tweets/post/index.ts @@ -0,0 +1,12 @@ +/* eslint-disable */ +import type * as Types from '../../@types' + +export type Methods = { + post: { + status: 200 + /** success */ + resBody: Types.CreateTweetResponse + /** tweet to delete */ + reqBody: Types.CreateTweetPayload + } +}