-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path{teamId}.ts
More file actions
43 lines (41 loc) · 1.29 KB
/
{teamId}.ts
File metadata and controls
43 lines (41 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Debug from 'debug'
import { Operation, OperationHandlerArray } from 'express-openapi'
import { AplTeamSettingsRequest, OpenApiRequestExt } from 'src/otomi-models'
const debug = Debug('otomi:api:v2:teams')
export default function (): OperationHandlerArray {
const del: Operation = [
async ({ otomi, params: { teamId } }: OpenApiRequestExt, res): Promise<void> => {
debug(`deleteTeam(${teamId})`)
await otomi.deleteTeam(teamId)
res.json({})
},
]
const get: Operation = [
({ otomi, params: { teamId } }: OpenApiRequestExt, res): void => {
debug(`getTeam(${teamId})`)
const data = otomi.getAplTeam(teamId)
res.json(data)
},
]
const put: Operation = [
async ({ otomi, params: { teamId }, body }: OpenApiRequestExt, res): Promise<void> => {
debug(`editTeam(${teamId})`)
const data = await otomi.editAplTeam(teamId, body as AplTeamSettingsRequest)
res.json(data)
},
]
const patch: Operation = [
async ({ otomi, params: { teamId }, body }: OpenApiRequestExt, res): Promise<void> => {
debug(`editTeam(${teamId}, patch)`)
const data = await otomi.editAplTeam(teamId, body as AplTeamSettingsRequest, true)
res.json(data)
},
]
const api = {
delete: del,
get,
put,
patch,
}
return api
}