diff --git a/products/backend/src/index.ts b/products/backend/src/index.ts index ed1b9ad..4fc0e9d 100644 --- a/products/backend/src/index.ts +++ b/products/backend/src/index.ts @@ -65,9 +65,9 @@ app.onError((error, c) => { app.doc('/openapi', { openapi: '3.1.0', info: { - title: 'Echo API', - version: '1.0.0', - description: '受け取った入力値をそのまま応答するAPI', + title: 'Pay Crew2 API', + version: '0.0.1', + description: 'API documentation for Pay Crew2 backend', }, }); diff --git a/products/backend/src/presentation/api.protected.ts b/products/backend/src/presentation/api.protected.ts index e4025b6..e77d90c 100644 --- a/products/backend/src/presentation/api.protected.ts +++ b/products/backend/src/presentation/api.protected.ts @@ -5,7 +5,6 @@ import honoFactory from './factory/hono'; // better-auth object factory import { AuthFactoryType } from './factory/auth'; // routes -import sample from './routes/sample'; import info from './routes/info'; import group from './routes/group'; import userProfile from './routes/userProfile'; @@ -31,7 +30,6 @@ const apiProtected = (auth: AuthFactoryType) => { }); //* endpoint registration *// - app.route('/', sample); app.route('/', info); app.route('/', group); app.route('/', userProfile); diff --git a/products/backend/src/presentation/factory/hono.ts b/products/backend/src/presentation/factory/hono.ts index cd2effe..399a708 100644 --- a/products/backend/src/presentation/factory/hono.ts +++ b/products/backend/src/presentation/factory/hono.ts @@ -20,6 +20,13 @@ const honoFactory = () => { }, }); + // セキュリティスキームの登録 + app.openAPIRegistry.registerComponent('securitySchemes', 'SessionCookie', { + type: 'apiKey', + in: 'cookie', + name: 'better-auth.session_token', + }); + return app; }; diff --git a/products/backend/src/presentation/routes/group.ts b/products/backend/src/presentation/routes/group.ts index 8e6456e..4d5ac4a 100644 --- a/products/backend/src/presentation/routes/group.ts +++ b/products/backend/src/presentation/routes/group.ts @@ -40,6 +40,7 @@ const createGroupSchema = route.createSchema( path: '/api/group/create', method: 'post', description: 'create a new group', + security: [{ SessionCookie: [] }], request: { body: { required: true, @@ -125,6 +126,7 @@ const joinGroupSchema = route.createSchema( path: '/api/group/join', method: 'post', description: 'join an existing group', + security: [{ SessionCookie: [] }], request: { body: { required: true, @@ -197,6 +199,7 @@ const getGroupInfoSchema = route.createSchema( path: '/api/group/info', method: 'post', description: 'get group information', + security: [{ SessionCookie: [] }], request: { body: { required: true, @@ -331,6 +334,7 @@ const getGroupDebtHistorySchema = route.createSchema( path: '/api/group/debt/history', method: 'post', description: 'get group debt history', + security: [{ SessionCookie: [] }], request: { body: { required: true, @@ -456,6 +460,7 @@ const registerGroupDebtSchema = route.createSchema( path: '/api/group/debt/register', method: 'post', description: 'register group debt entry', + security: [{ SessionCookie: [] }], request: { body: { required: true, @@ -542,6 +547,7 @@ const deleteGroupDebtSchema = route.createSchema( path: '/api/group/debt/delete', method: 'delete', description: 'delete group debt entry', + security: [{ SessionCookie: [] }], request: { body: { required: true, diff --git a/products/backend/src/presentation/routes/info.ts b/products/backend/src/presentation/routes/info.ts index dfb4df3..0634a47 100644 --- a/products/backend/src/presentation/routes/info.ts +++ b/products/backend/src/presentation/routes/info.ts @@ -30,6 +30,7 @@ const infoAboutGroupsTheUserBelongsToSchema = route.createSchema( path: '/api/info/group', method: 'get', description: 'get info about groups the user belongs to', + security: [{ SessionCookie: [] }], request: {}, responses: { 200: { @@ -129,6 +130,7 @@ const infoAboutUserTransactionsSchema = route.createSchema( path: '/api/info/transaction', method: 'get', description: 'get info about user transactions', + security: [{ SessionCookie: [] }], request: {}, responses: { 200: { @@ -247,6 +249,7 @@ const infoUserRepaymentSchema = route.createSchema( path: '/api/info/transaction', method: 'delete', description: 'do user repayment', + security: [{ SessionCookie: [] }], request: { body: { required: true, diff --git a/products/backend/src/presentation/routes/sample.ts b/products/backend/src/presentation/routes/sample.ts deleted file mode 100644 index abb213d..0000000 --- a/products/backend/src/presentation/routes/sample.ts +++ /dev/null @@ -1,45 +0,0 @@ -// hono instance -import honoFactory from '../factory/hono'; -// validator -import { sampleSchema, type SampleSchemaType } from 'validator'; -// error schema -import { route } from '../share/error'; - -const hono = honoFactory(); - -// サンプルエンドポイントの登録 -const sampleGetSchema = route.createSchema( - { - path: '/api/session', - method: 'get', - description: 'sample endpoint to get session info', - request: {}, - responses: { - 200: { - description: 'OK', - content: { - 'application/json': { - schema: sampleSchema, - }, - }, - }, - }, - }, - [401, 500] as const -); - -hono.openapi(sampleGetSchema, (c) => { - // const session = c.get('session'); - const user = c.get('user'); - - // return response - return c.json( - { - id: user.id, - email: user.email, - } satisfies SampleSchemaType, - 200 - ); -}); - -export default hono; diff --git a/products/backend/src/presentation/routes/userProfile.ts b/products/backend/src/presentation/routes/userProfile.ts index 43a4281..5fa3170 100644 --- a/products/backend/src/presentation/routes/userProfile.ts +++ b/products/backend/src/presentation/routes/userProfile.ts @@ -24,6 +24,7 @@ const getUserProfile = route.createSchema( path: '/api/profile', method: 'get', description: 'get user profile', + security: [{ SessionCookie: [] }], request: {}, responses: { 200: { @@ -80,6 +81,7 @@ const updateUserProfile = route.createSchema( path: '/api/profile', method: 'put', description: 'update user profile', + security: [{ SessionCookie: [] }], request: { body: { required: true, diff --git a/products/frontend/openapi.json b/products/frontend/openapi.json index 258e298..0789491 100644 --- a/products/frontend/openapi.json +++ b/products/frontend/openapi.json @@ -1,825 +1,35 @@ { "openapi": "3.1.0", - "info": { - "title": "Pay Crew2 API", - "version": "0.0.1", - "description": "API documentation for Pay Crew2 backend" - }, - "components": { - "schemas": {}, - "parameters": {} - }, - "paths": { - "/api/session": { - "get": { - "description": "sample endpoint to get session info", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "minLength": 1 - }, - "email": { - "type": "string", - "minLength": 1 - } - }, - "required": [ - "id", - "email" - ] - } - } - } - }, - "401": { - "description": "Unauthorized", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "status": { - "anyOf": [ - { - "type": "number", - "enum": [ - 100 - ] - }, - { - "type": "number", - "enum": [ - 102 - ] - }, - { - "type": "number", - "enum": [ - 103 - ] - }, - { - "type": "number", - "enum": [ - 200 - ] - }, - { - "type": "number", - "enum": [ - 201 - ] - }, - { - "type": "number", - "enum": [ - 202 - ] - }, - { - "type": "number", - "enum": [ - 203 - ] - }, - { - "type": "number", - "enum": [ - 206 - ] - }, - { - "type": "number", - "enum": [ - 207 - ] - }, - { - "type": "number", - "enum": [ - 208 - ] - }, - { - "type": "number", - "enum": [ - 226 - ] - }, - { - "type": "number", - "enum": [ - 300 - ] - }, - { - "type": "number", - "enum": [ - 301 - ] - }, - { - "type": "number", - "enum": [ - 302 - ] - }, - { - "type": "number", - "enum": [ - 303 - ] - }, - { - "type": "number", - "enum": [ - 305 - ] - }, - { - "type": "number", - "enum": [ - 306 - ] - }, - { - "type": "number", - "enum": [ - 307 - ] - }, - { - "type": "number", - "enum": [ - 308 - ] - }, - { - "type": "number", - "enum": [ - 400 - ] - }, - { - "type": "number", - "enum": [ - 401 - ] - }, - { - "type": "number", - "enum": [ - 402 - ] - }, - { - "type": "number", - "enum": [ - 403 - ] - }, - { - "type": "number", - "enum": [ - 404 - ] - }, - { - "type": "number", - "enum": [ - 405 - ] - }, - { - "type": "number", - "enum": [ - 406 - ] - }, - { - "type": "number", - "enum": [ - 407 - ] - }, - { - "type": "number", - "enum": [ - 408 - ] - }, - { - "type": "number", - "enum": [ - 409 - ] - }, - { - "type": "number", - "enum": [ - 410 - ] - }, - { - "type": "number", - "enum": [ - 411 - ] - }, - { - "type": "number", - "enum": [ - 412 - ] - }, - { - "type": "number", - "enum": [ - 413 - ] - }, - { - "type": "number", - "enum": [ - 414 - ] - }, - { - "type": "number", - "enum": [ - 415 - ] - }, - { - "type": "number", - "enum": [ - 416 - ] - }, - { - "type": "number", - "enum": [ - 417 - ] - }, - { - "type": "number", - "enum": [ - 418 - ] - }, - { - "type": "number", - "enum": [ - 421 - ] - }, - { - "type": "number", - "enum": [ - 422 - ] - }, - { - "type": "number", - "enum": [ - 423 - ] - }, - { - "type": "number", - "enum": [ - 424 - ] - }, - { - "type": "number", - "enum": [ - 425 - ] - }, - { - "type": "number", - "enum": [ - 426 - ] - }, - { - "type": "number", - "enum": [ - 428 - ] - }, - { - "type": "number", - "enum": [ - 429 - ] - }, - { - "type": "number", - "enum": [ - 431 - ] - }, - { - "type": "number", - "enum": [ - 451 - ] - }, - { - "type": "number", - "enum": [ - 500 - ] - }, - { - "type": "number", - "enum": [ - 501 - ] - }, - { - "type": "number", - "enum": [ - 502 - ] - }, - { - "type": "number", - "enum": [ - 503 - ] - }, - { - "type": "number", - "enum": [ - 504 - ] - }, - { - "type": "number", - "enum": [ - 505 - ] - }, - { - "type": "number", - "enum": [ - 506 - ] - }, - { - "type": "number", - "enum": [ - 507 - ] - }, - { - "type": "number", - "enum": [ - 508 - ] - }, - { - "type": "number", - "enum": [ - 510 - ] - }, - { - "type": "number", - "enum": [ - 511 - ] - }, - { - "type": "number", - "enum": [ - -1 - ] - } - ], - "example": 400, - "description": "HTTPステータスコード" - }, - "message": { - "type": "string", - "minLength": 1, - "example": "Bad Request", - "description": "エラーメッセージ" - } - }, - "required": [ - "status", - "message" - ] - } - } - } - }, - "500": { - "description": "Internal Server Error", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "status": { - "anyOf": [ - { - "type": "number", - "enum": [ - 100 - ] - }, - { - "type": "number", - "enum": [ - 102 - ] - }, - { - "type": "number", - "enum": [ - 103 - ] - }, - { - "type": "number", - "enum": [ - 200 - ] - }, - { - "type": "number", - "enum": [ - 201 - ] - }, - { - "type": "number", - "enum": [ - 202 - ] - }, - { - "type": "number", - "enum": [ - 203 - ] - }, - { - "type": "number", - "enum": [ - 206 - ] - }, - { - "type": "number", - "enum": [ - 207 - ] - }, - { - "type": "number", - "enum": [ - 208 - ] - }, - { - "type": "number", - "enum": [ - 226 - ] - }, - { - "type": "number", - "enum": [ - 300 - ] - }, - { - "type": "number", - "enum": [ - 301 - ] - }, - { - "type": "number", - "enum": [ - 302 - ] - }, - { - "type": "number", - "enum": [ - 303 - ] - }, - { - "type": "number", - "enum": [ - 305 - ] - }, - { - "type": "number", - "enum": [ - 306 - ] - }, - { - "type": "number", - "enum": [ - 307 - ] - }, - { - "type": "number", - "enum": [ - 308 - ] - }, - { - "type": "number", - "enum": [ - 400 - ] - }, - { - "type": "number", - "enum": [ - 401 - ] - }, - { - "type": "number", - "enum": [ - 402 - ] - }, - { - "type": "number", - "enum": [ - 403 - ] - }, - { - "type": "number", - "enum": [ - 404 - ] - }, - { - "type": "number", - "enum": [ - 405 - ] - }, - { - "type": "number", - "enum": [ - 406 - ] - }, - { - "type": "number", - "enum": [ - 407 - ] - }, - { - "type": "number", - "enum": [ - 408 - ] - }, - { - "type": "number", - "enum": [ - 409 - ] - }, - { - "type": "number", - "enum": [ - 410 - ] - }, - { - "type": "number", - "enum": [ - 411 - ] - }, - { - "type": "number", - "enum": [ - 412 - ] - }, - { - "type": "number", - "enum": [ - 413 - ] - }, - { - "type": "number", - "enum": [ - 414 - ] - }, - { - "type": "number", - "enum": [ - 415 - ] - }, - { - "type": "number", - "enum": [ - 416 - ] - }, - { - "type": "number", - "enum": [ - 417 - ] - }, - { - "type": "number", - "enum": [ - 418 - ] - }, - { - "type": "number", - "enum": [ - 421 - ] - }, - { - "type": "number", - "enum": [ - 422 - ] - }, - { - "type": "number", - "enum": [ - 423 - ] - }, - { - "type": "number", - "enum": [ - 424 - ] - }, - { - "type": "number", - "enum": [ - 425 - ] - }, - { - "type": "number", - "enum": [ - 426 - ] - }, - { - "type": "number", - "enum": [ - 428 - ] - }, - { - "type": "number", - "enum": [ - 429 - ] - }, - { - "type": "number", - "enum": [ - 431 - ] - }, - { - "type": "number", - "enum": [ - 451 - ] - }, - { - "type": "number", - "enum": [ - 500 - ] - }, - { - "type": "number", - "enum": [ - 501 - ] - }, - { - "type": "number", - "enum": [ - 502 - ] - }, - { - "type": "number", - "enum": [ - 503 - ] - }, - { - "type": "number", - "enum": [ - 504 - ] - }, - { - "type": "number", - "enum": [ - 505 - ] - }, - { - "type": "number", - "enum": [ - 506 - ] - }, - { - "type": "number", - "enum": [ - 507 - ] - }, - { - "type": "number", - "enum": [ - 508 - ] - }, - { - "type": "number", - "enum": [ - 510 - ] - }, - { - "type": "number", - "enum": [ - 511 - ] - }, - { - "type": "number", - "enum": [ - -1 - ] - } - ], - "example": 400, - "description": "HTTPステータスコード" - }, - "message": { - "type": "string", - "minLength": 1, - "example": "Bad Request", - "description": "エラーメッセージ" - } - }, - "required": [ - "status", - "message" - ] - } - } - } - } - } + "security": [ + { + "SessionCookie": [] + } + ], + "info": { + "title": "Pay Crew2 API", + "version": "0.0.1", + "description": "API documentation for Pay Crew2 backend" + }, + "components": { + "securitySchemes": { + "SessionCookie": { + "type": "apiKey", + "in": "cookie", + "name": "better-auth.session_token" } }, + "schemas": {}, + "parameters": {} + }, + "paths": { "/api/info/group": { "get": { "description": "get info about groups the user belongs to", + "security": [ + { + "SessionCookie": [] + } + ], "responses": { "200": { "description": "OK", @@ -1664,6 +874,11 @@ "/api/info/transaction": { "get": { "description": "get info about user transactions", + "security": [ + { + "SessionCookie": [] + } + ], "responses": { "200": { "description": "OK", @@ -2485,6 +1700,11 @@ }, "delete": { "description": "do user repayment", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { @@ -3694,6 +2914,11 @@ "/api/group/create": { "post": { "description": "create a new group", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { @@ -4908,6 +4133,11 @@ "/api/group/join": { "post": { "description": "join an existing group", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { @@ -6117,6 +5347,11 @@ "/api/group/info": { "post": { "description": "get group information", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { @@ -7352,6 +6587,11 @@ "/api/group/debt/history": { "post": { "description": "get group debt history", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { @@ -8597,6 +7837,11 @@ "/api/group/debt/register": { "post": { "description": "register group debt entry", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { @@ -9842,6 +9087,11 @@ "/api/group/debt/delete": { "delete": { "description": "delete group debt entry", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { @@ -11056,6 +10306,11 @@ "/api/profile": { "get": { "description": "get user profile", + "security": [ + { + "SessionCookie": [] + } + ], "responses": { "200": { "description": "OK", @@ -12253,6 +11508,11 @@ }, "put": { "description": "update user profile", + "security": [ + { + "SessionCookie": [] + } + ], "requestBody": { "required": true, "content": { diff --git a/products/frontend/src/routes/GenerateGroup/index.tsx b/products/frontend/src/routes/GenerateGroup/index.tsx index 7a9f281..ddb1360 100644 --- a/products/frontend/src/routes/GenerateGroup/index.tsx +++ b/products/frontend/src/routes/GenerateGroup/index.tsx @@ -69,16 +69,16 @@ const GenerateGroup: FC = () => {

{isSuccess && !isResultError && result ? ( -
+ <>

グループ作成結果

グループID: {result.group_id}

招待ID: {result.invite_id}

-
+ ) : isResultError ? ( -
+ <>

グループ作成結果

グループの作成に失敗しました。再度お試しください。

-
+ ) : null} ); diff --git a/products/frontend/src/routes/GroupDetail/index.tsx b/products/frontend/src/routes/GroupDetail/index.tsx index 4234e44..3b39400 100644 --- a/products/frontend/src/routes/GroupDetail/index.tsx +++ b/products/frontend/src/routes/GroupDetail/index.tsx @@ -130,10 +130,9 @@ const GroupDetail: FC = () => { return ( <> -

グループ

-

グループ情報

+

グループ情報

{groupInfoMutation.isSuccess && !isGroupInfoResultError && groupInfoResult ? ( -
+ <>

グループ名: {groupInfoResult.group_name}

作成者: {groupInfoResult.created_by}

メンバー一覧

@@ -187,33 +186,24 @@ const GroupDetail: FC = () => { : ''}

-
+ ) : isGroupInfoResultError ? ( -
-

グループ情報の取得に失敗しました。再度お試しください。

-
+

グループ情報の取得に失敗しました。再度お試しください。

) : null}

グループの貸し借りの履歴

{debtHistoryMutation.isSuccess && !isDebtHistoryResultError && debtHistoryResult ? ( -
- -
+ ) : isDebtHistoryResultError ? ( -
-

グループの履歴の取得に失敗しました。再度お試しください。

-
+

グループの履歴の取得に失敗しました。再度お試しください。

) : null} ); diff --git a/products/frontend/src/routes/Invite/index.tsx b/products/frontend/src/routes/Invite/index.tsx index 35ba3d1..6f84ad1 100644 --- a/products/frontend/src/routes/Invite/index.tsx +++ b/products/frontend/src/routes/Invite/index.tsx @@ -33,16 +33,16 @@ const Invite: FC = () => { {result &&

参加したグループID: {result}

} {isError &&

エラーが発生しました: {error.message}

} {isSuccess && !isResultError && result ? ( -
+ <>

グループ参加結果

グループID: {result} に参加しました。

グループページへ移動 -
+ ) : isResultError ? ( -
+ <>

グループ参加結果

グループの参加に失敗しました。再度お試しください。

-
+ ) : null} ); diff --git a/products/frontend/src/routes/Root/index.tsx b/products/frontend/src/routes/Root/index.tsx index e2c8510..de8dc5a 100644 --- a/products/frontend/src/routes/Root/index.tsx +++ b/products/frontend/src/routes/Root/index.tsx @@ -48,7 +48,7 @@ const Root: FC = () => { }; return ( -
+ <>

Hello, World!

@@ -115,7 +115,7 @@ const Root: FC = () => { )} )} -
+ ); };