-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathteams.ts
More file actions
34 lines (31 loc) · 971 Bytes
/
teams.ts
File metadata and controls
34 lines (31 loc) · 971 Bytes
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
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 get: Operation = [
({ otomi }: OpenApiRequestExt, res): void => {
debug('getTeams')
// we filter admin team here as it is not for console
const teams = (otomi.getAplTeams() || [])
.filter((t) => t.metadata.name !== 'admin')
.map(({ spec, ...rest }) => ({
...rest,
spec: { ...spec, password: undefined },
}))
res.json(teams)
},
]
const post: Operation = [
async ({ otomi, body }: OpenApiRequestExt, res): Promise<void> => {
debug('createTeam')
const data = await otomi.createAplTeam(body as AplTeamSettingsRequest)
res.json(data)
},
]
const api = {
get,
post,
}
return api
}