-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfeatures.controller.ts
More file actions
108 lines (96 loc) · 3.37 KB
/
features.controller.ts
File metadata and controls
108 lines (96 loc) · 3.37 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {
Body,
Controller,
Get,
Logger,
Param,
ParseBoolPipe,
Post,
Query,
} from '@nestjs/common'
import {
FeatureIdsSearchDto,
FeatureRangeSearchDto,
} from '../entity/gff3Object.dto'
import { Role } from '../utils/role/role.enum'
import { Validations } from '../utils/validation/validatation.decorator'
import { FeatureCountRequest, GetByIndexedIdRequest } from './dto/feature.dto'
import { FeaturesService } from './features.service'
@Validations(Role.ReadOnly)
@Controller('features')
export class FeaturesController {
constructor(private readonly featuresService: FeaturesService) {}
private readonly logger = new Logger(FeaturesController.name)
/**
* Search database for queries
* For testing try to go to:
* http://localhost:3999/features/searchFeatures?term=exonerate
*/
@Get('searchFeatures')
async searchFeatures(@Query() request: { term: string; assemblies: string }) {
return this.featuresService.searchFeatures(request)
}
/**
* Fetch features based on Reference seq, Start and End -values
* @param request - Contain search criteria i.e. refSeq, start and end -parameters
* @returns Return 'HttpStatus.OK' and array of features if search was successful
* or if search data was not found or in case of error throw exception
*/
@Get('getFeatures')
getFeaturesByRange(@Query() request: FeatureRangeSearchDto) {
this.logger.debug(
`getFeatures endpoint: refSeq: ${request.refSeq}, start: ${request.start}, end: ${request.end}`,
)
return this.featuresService.findByRange(request)
}
@Post('getByIds')
findByFeatureIds(@Body() request: FeatureIdsSearchDto) {
this.logger.debug(`: featureIds: ${JSON.stringify(request.featureIds)}`)
return this.featuresService.findByFeatureIds(
request.featureIds,
request.topLevel,
)
}
@Get('count')
async getFeatureCount(@Query() featureCountRequest: FeatureCountRequest) {
this.logger.debug(
`Get features count by ${JSON.stringify(featureCountRequest)}`,
)
const count =
await this.featuresService.getFeatureCount(featureCountRequest)
return { count }
}
@Get('getByIndexedId')
async getById(@Query() getByIndexedIdRequest: GetByIndexedIdRequest) {
return this.featuresService.getByIndexedId(getByIndexedIdRequest)
}
/**
* Get feature by featureId. When retrieving features by id, the features and any of its children are returned, but not any of its parent or sibling features.
* @param featureid - featureId
* @returns Return 'HttpStatus.OK' and the feature(s) if search was successful
* or if search data was not found or in case of error throw exception
*/
@Get(':featureid')
getFeature(
@Param('featureid') featureid: string,
@Query('topLevel', new ParseBoolPipe({ optional: true }))
topLevel: boolean | undefined,
) {
this.logger.debug(`Get feature by featureId: ${featureid}`)
return this.featuresService.findById(featureid, topLevel)
}
@Get('check/:featureid')
checkFeature(@Param('featureid') featureid: string) {
return this.featuresService.checkFeature(featureid)
}
/**
* Fetch all features
* @returns Return 'HttpStatus.OK' and array of features if search was successful
* or if search data was not found or in case of error throw exception
*/
@Get()
getAll() {
this.logger.debug('Get all features')
return this.featuresService.findAll()
}
}