Skip to content

Commit

Permalink
feat: msw handlers to external package
Browse files Browse the repository at this point in the history
  • Loading branch information
tosaken1116 committed Apr 13, 2024
1 parent c3576c4 commit 4c918cc
Show file tree
Hide file tree
Showing 19 changed files with 2,435 additions and 746 deletions.
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ _templates/
setup.js
*.config.*

src/api/**/*
src/api/**/*

msw/

public/mockServiceWorker.js
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "schema"]
path = schema
url = [email protected]:Kyutech-C3/Toybox_schema.git
[submodule "protoc-plugin"]
path = protoc-plugin
url = [email protected]:Kyutech-C3/protoc-plugin.git
12 changes: 12 additions & 0 deletions msw/handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { assetsServiceHandlers } from './handlers/AssetsService/handlers.ts'
import { authServiceHandlers } from './handlers/AuthService/handlers.ts'
import { tagsServiceHandlers } from './handlers/TagsService/handlers.ts'
import { usersServiceHandlers } from './handlers/UsersService/handlers.ts'
import { worksServiceHandlers } from './handlers/WorksService/handlers.ts'
export const handlers = [
...assetsServiceHandlers,
...authServiceHandlers,
...tagsServiceHandlers,
...usersServiceHandlers,
...worksServiceHandlers,
]
18 changes: 18 additions & 0 deletions msw/handlers/AssetsService/handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable */
/* This file is generated by protoc-gen-ts-msw-handlers */
/* Do not edit this file manually */
import { http, HttpResponse } from 'msw'
const ApiV1AssetsPostHandler = http.post('/api/v1/assets',() => {
return HttpResponse.json({
id:'811ffd91-3ef0-41ed-a0f5-ee83d6ae8a3e',
})
})
const ApiV1AssetsIdDeleteHandler = http.delete('/api/v1/assets/{id}',() => {
return HttpResponse.json({
status:'ok',
})
})
export const assetsServiceHandlers = [
ApiV1AssetsPostHandler,
ApiV1AssetsIdDeleteHandler,
]
40 changes: 40 additions & 0 deletions msw/handlers/AuthService/handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint-disable */
/* This file is generated by protoc-gen-ts-msw-handlers */
/* Do not edit this file manually */
import { http, HttpResponse } from 'msw'
const ApiV1AuthDiscordCallbackGetHandler = http.get('/api/v1/auth/discord/callback',() => {
return HttpResponse.json({
value:'',
})
})
const ApiV1AuthTokenPostHandler = http.post('/api/v1/auth/token',() => {
return HttpResponse.json({
expired_at:'',
refresh_token:'y{l{hijtqjtzgvxp',
access_token:'y{l{hijtqjtzgvxp',
})
})
const ApiV1AuthDiscordGetHandler = http.get('/api/v1/auth/discord',() => {
return HttpResponse.json({
value:'',
})
})
const ApiV1AuthSignUpPostHandler = http.post('/api/v1/auth/sign_up',() => {
return HttpResponse.json({
id:'01bad699-054d-45ef-aa8f-86ba01ef5fb4',
name:'Asa Gulgowski',
display_name:'Asa Gulgowski',
avatar_url:'https://www.wed.biz/xrw-pnx',
profile:'aut sunt dignissimos amet dicta voluptates cupiditate aut numquam dolorem minima numquam culpa iure voluptatibus consequuntur ipsa animi quo dolores eum voluptatum aut repellat voluptas et fugiat adipisci ut ipsam dolores vero molestiae doloribus eos est tempore odio illum est.',
twitter_id:'103c831d-0c5b-4576-9c0a-c86b334ab11e',
github_id:'17ff1139-628e-4b85-9c4c-1de9e8c4560f',
created_at:'2021-09-01T00:00:00Z',
updated_at:'2021-09-01T00:00:00Z',
})
})
export const authServiceHandlers = [
ApiV1AuthDiscordCallbackGetHandler,
ApiV1AuthTokenPostHandler,
ApiV1AuthDiscordGetHandler,
ApiV1AuthSignUpPostHandler,
]
53 changes: 53 additions & 0 deletions msw/handlers/TagsService/handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* eslint-disable */
/* This file is generated by protoc-gen-ts-msw-handlers */
/* Do not edit this file manually */
import { http, HttpResponse } from 'msw'
const ApiV1TagsGetHandler = http.get('/api/v1/tags',() => {
return HttpResponse.json({
tags:[
{
id:'35701d5c-a7ce-4f16-8eb6-397840646007',
name:'Asa Gulgowski',
color:'#C44549',
},
{
id:'95c20d45-b46a-427e-a782-15ada4e9056b',
name:'Asa Gulgowski',
color:'#C44549',
},
],
})
})
const ApiV1TagsPostHandler = http.post('/api/v1/tags',() => {
return HttpResponse.json({
id:'efae644f-51cf-4b2c-965d-a3f7243a12b5',
name:'Asa Gulgowski',
color:'#C44549',
})
})
const ApiV1TagsTagIdGetHandler = http.get('/api/v1/tags/{tag_id}',() => {
return HttpResponse.json({
id:'a8f94ea5-c492-44b8-8370-1acfacad805a',
name:'Asa Gulgowski',
color:'#C44549',
})
})
const ApiV1TagsTagIdPutHandler = http.put('/api/v1/tags/{tag_id}',() => {
return HttpResponse.json({
id:'34b9c70c-0c92-4934-899a-617617071798',
name:'Asa Gulgowski',
color:'#C44549',
})
})
const ApiV1TagsTagIdDeleteHandler = http.delete('/api/v1/tags/{tag_id}',() => {
return HttpResponse.json({
message:'',
})
})
export const tagsServiceHandlers = [
ApiV1TagsGetHandler,
ApiV1TagsPostHandler,
ApiV1TagsTagIdGetHandler,
ApiV1TagsTagIdPutHandler,
ApiV1TagsTagIdDeleteHandler,
]
Loading

0 comments on commit 4c918cc

Please sign in to comment.