Skip to content

Commit f8a4066

Browse files
committed
chore: API 파라미터 타입 정의
1 parent 0dac892 commit f8a4066

File tree

10 files changed

+28
-10
lines changed

10 files changed

+28
-10
lines changed

client/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"src/*": ["./src/*"],
66
"components/*": ["./src/components/*"],
77
"config": ["./src/config"],
8-
"styles/*": ["./src/styles/*"]
8+
"styles/*": ["./src/styles/*"],
9+
"params/*": ["../types/params/*"]
910
},
1011
"target": "ESNext",
1112
"useDefineForClassFields": true,

client/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig({
1515
},
1616
{ find: 'config', replacement: resolve(__dirname, './src/config') },
1717
{ find: 'styles', replacement: resolve(__dirname, './src/styles') },
18+
{ find: 'params', replacement: resolve(__dirname, '../types/params') },
1819
],
1920
},
2021
});

server/apis/auth/controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import asyncWrapper from '@utils/async-wrapper';
33
import jwtAuthenticator from '@middlewares/jwt-authenticator';
44
import * as authService from './service';
55
import { OK, CREATED } from '@constants/http-status';
6+
import { postLoginParams } from '@params/auth';
67

78
interface CookieOptions {
89
httpOnly: boolean;
@@ -23,7 +24,7 @@ router.get(
2324

2425
router.post(
2526
'/login',
26-
asyncWrapper(async (req: Request, res: Response) => {
27+
asyncWrapper(async (req: Request<postLoginParams>, res: Response) => {
2728
const { code } = req.body;
2829

2930
const { user, loginToken, refreshToken } = await authService.login(code);

server/apis/user/controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import express, { Request, Response } from 'express';
22
import asyncWrapper from '@utils/async-wrapper';
33
import * as userService from './service';
44
import jwtAuthenticator from '@middlewares/jwt-authenticator';
5+
import { getWorkspaceParams } from '@params/user';
56

67
const router = express.Router();
78

89
router.get(
910
'/:id/workspace',
1011
jwtAuthenticator,
11-
asyncWrapper(async (req: Request, res: Response) => {
12+
asyncWrapper(async (req: Request<getWorkspaceParams>, res: Response) => {
1213
const { id: userId } = req.user;
1314
const { id: targetUserId } = req.params;
1415

server/apis/workspace/controller.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@ import express, { Request, Response } from 'express';
22
import asyncWrapper from '@utils/async-wrapper';
33
import jwtAuthenticator from '@middlewares/jwt-authenticator';
44
import * as workspaceService from './service';
5-
import { OK } from '@constants/http-status';
5+
import { CREATED } from '@constants/http-status';
6+
import { postParams, postJoinParams } from '@params/workspace';
67

78
const router = express.Router();
89

910
router.post(
1011
'/',
11-
asyncWrapper(async (req: Request, res: Response) => {
12+
asyncWrapper(async (req: Request<postParams>, res: Response) => {
1213
const { name } = req.body;
1314

1415
const workspace = await workspaceService.create(name);
1516

16-
res.status(OK).send({ ...workspace });
17+
res.status(CREATED).send({ ...workspace });
1718
}),
1819
);
1920

2021
router.post(
2122
'/join',
2223
jwtAuthenticator,
23-
asyncWrapper(async (req: Request, res: Response) => {
24+
asyncWrapper(async (req: Request<postJoinParams>, res: Response) => {
2425
const { code } = req.body;
2526

2627
const joinedWorkspace = await workspaceService.join(req.user.id, code);
2728

28-
res.status(OK).send(joinedWorkspace);
29+
res.status(CREATED).send(joinedWorkspace);
2930
}),
3031
);
3132

server/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"esModuleInterop": true,
2020
"downlevelIteration": true,
2121
"typeRoots": ["../node_modules/@types", "./@types"],
22-
"rootDir": ".",
2322
"outDir": "./dist",
2423
"plugins": [
2524
{

server/tsconfig.path.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"@errors/*": ["errors/*"],
99
"@db": ["db"],
1010
"@middlewares/*": ["middlewares/*"],
11-
"@utils/*": ["utils/*"]
11+
"@utils/*": ["utils/*"],
12+
"@params/*": ["../types/params/*"]
1213
}
1314
}
1415
}

types/params/auth.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface postLoginParams {
2+
code: string;
3+
}

types/params/user.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface getWorkspaceParams {
2+
id: number;
3+
}

types/params/workspace.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface postParams {
2+
name: string;
3+
}
4+
5+
export interface postJoinParams {
6+
code: string;
7+
}

0 commit comments

Comments
 (0)