File tree 4 files changed +11
-8
lines changed
4 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ interface GetQuery {
7
7
}
8
8
9
9
export const get : ApiController < GetQuery > = {
10
- url : "/samples" ,
11
10
handler : async function ( request , reply ) {
12
11
logger . info ( "Fetching samples" , { requestId : request . id } ) ;
13
12
const sampleRepository = this . db . getCustomRepository ( SampleRepository ) ;
@@ -17,6 +16,7 @@ export const get: ApiController<GetQuery> = {
17
16
reply . send ( await sampleRepository . find ( ) ) ;
18
17
}
19
18
} ,
19
+
20
20
opts : {
21
21
schema : {
22
22
querystring : {
Original file line number Diff line number Diff line change 1
1
import { FastifyInstance } from "fastify" ;
2
2
3
- import * as sampleController from "../controllers /sample" ;
3
+ import { sampleRoutes } from "./sample" ;
4
4
5
5
export function registerRoutes ( server : FastifyInstance ) : void {
6
- server . get (
7
- sampleController . get . url ,
8
- sampleController . get . opts ,
9
- sampleController . get . handler
10
- ) ;
6
+ server . register ( sampleRoutes , { prefix : "/samples" } ) ;
11
7
}
Original file line number Diff line number Diff line change
1
+ import { FastifyInstance } from "fastify" ;
2
+
3
+ import * as SampleController from "../controllers/sample" ;
4
+
5
+ // /samples prefix
6
+ export async function sampleRoutes ( server : FastifyInstance ) : Promise < void > {
7
+ server . get ( "/" , SampleController . get . opts , SampleController . get . handler ) ;
8
+ }
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ export interface ApiController<
21
21
Body = DefaultBody ,
22
22
Headers = DefaultHeaders
23
23
> {
24
- url : string ;
25
24
opts : RouteShorthandOptions ;
26
25
handler : RouteHandlerMethod <
27
26
RawServerDefault ,
You can’t perform that action at this time.
0 commit comments