File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { ServiceRegistry , ServiceType , SurveyService } from '@openforis/arena-core'
2+
3+ import { ServerServiceType } from '../../server/arenaServer/serverServiceType'
4+ import { UserGroupService } from '../../service'
5+
6+ export const getUserGroupService = ( ) : UserGroupService =>
7+ ServiceRegistry . getInstance ( ) . getService ( ServerServiceType . userGroup ) as UserGroupService
8+
9+ export const getSurveyUuid = async ( surveyId : number ) : Promise < string > => {
10+ const surveyService = ServiceRegistry . getInstance ( ) . getService ( ServiceType . survey ) as SurveyService
11+ const survey = await surveyService . get ( { surveyId } )
12+ return survey . uuid
13+ }
Original file line number Diff line number Diff line change 11import { Express } from 'express'
22
3- import { ServiceRegistry , ServiceType , SurveyService } from '@openforis/arena-core'
4-
53import { ExpressInitializer } from '../../server'
6- import { ServerServiceType } from '../../server/arenaServer/serverServiceType'
7- import { UserGroupService } from '../../service'
84import { Requests } from '../../utils'
95
106import { ApiEndpoint } from '../endpoint'
117import { ApiAuthMiddleware } from '../middleware'
8+ import { getSurveyUuid , getUserGroupService } from './common'
129
1310const { requireUserGroupManagePermission } = ApiAuthMiddleware
1411
15- const getUserGroupService = ( ) : UserGroupService =>
16- ServiceRegistry . getInstance ( ) . getService ( ServerServiceType . userGroup ) as UserGroupService
17-
18- const getSurveyUuid = async ( surveyId : number ) : Promise < string > => {
19- const surveyService = ServiceRegistry . getInstance ( ) . getService ( ServiceType . survey ) as SurveyService
20- const survey = await surveyService . get ( { surveyId } )
21- return survey . uuid
22- }
23-
2412export const UserGroupCreate : ExpressInitializer = {
2513 init : ( express : Express ) : void => {
2614 express . post (
Original file line number Diff line number Diff line change 11import { Express } from 'express'
22
3- import { ServiceRegistry } from '@openforis/arena-core'
4-
53import { ExpressInitializer } from '../../server'
6- import { ServerServiceType } from '../../server/arenaServer/serverServiceType'
7- import { UserGroupService } from '../../service'
84import { Requests } from '../../utils'
95
106import { ApiEndpoint } from '../endpoint'
117import { ApiAuthMiddleware } from '../middleware'
8+ import { getUserGroupService } from './common'
129
1310const { requireUserGroupManagePermission } = ApiAuthMiddleware
1411
15- const getUserGroupService = ( ) : UserGroupService =>
16- ServiceRegistry . getInstance ( ) . getService ( ServerServiceType . userGroup ) as UserGroupService
17-
1812export const UserGroupDelete : ExpressInitializer = {
1913 init : ( express : Express ) : void => {
2014 express . delete (
Original file line number Diff line number Diff line change 11import { Express } from 'express'
22
3- import { ServiceRegistry , ServiceType , SurveyService } from '@openforis/arena-core'
4-
53import { ExpressInitializer } from '../../server'
6- import { ServerServiceType } from '../../server/arenaServer/serverServiceType'
7- import { UserGroupService } from '../../service'
84import { Requests } from '../../utils'
95
106import { ApiEndpoint } from '../endpoint'
117import { ApiAuthMiddleware } from '../middleware'
8+ import { getSurveyUuid , getUserGroupService } from './common'
129
1310const { requireSurveyViewPermission } = ApiAuthMiddleware
1411
15- const getUserGroupService = ( ) : UserGroupService =>
16- ServiceRegistry . getInstance ( ) . getService ( ServerServiceType . userGroup ) as UserGroupService
17-
18- const getSurveyUuid = async ( surveyId : number ) : Promise < string > => {
19- const surveyService = ServiceRegistry . getInstance ( ) . getService ( ServiceType . survey ) as SurveyService
20- const survey = await surveyService . get ( { surveyId } )
21- return survey . uuid
22- }
23-
2412export const UserGroupRead : ExpressInitializer = {
2513 init : ( express : Express ) : void => {
2614 express . get (
Original file line number Diff line number Diff line change 11import { Express } from 'express'
22
3- import { ServiceRegistry } from '@openforis/arena-core'
4-
53import { ExpressInitializer } from '../../server'
6- import { ServerServiceType } from '../../server/arenaServer/serverServiceType'
7- import { UserGroupService } from '../../service'
84import { Requests } from '../../utils'
95
106import { ApiEndpoint } from '../endpoint'
117import { ApiAuthMiddleware } from '../middleware'
8+ import { getUserGroupService } from './common'
129
1310const { requireUserGroupManagePermission } = ApiAuthMiddleware
1411
15- const getUserGroupService = ( ) : UserGroupService =>
16- ServiceRegistry . getInstance ( ) . getService ( ServerServiceType . userGroup ) as UserGroupService
17-
1812export const UserGroupUpdate : ExpressInitializer = {
1913 init : ( express : Express ) : void => {
2014 express . put (
You can’t perform that action at this time.
0 commit comments