File tree Expand file tree Collapse file tree 4 files changed +16
-8
lines changed
test-endpoints-router-module/test-app-express-cjs Expand file tree Collapse file tree 4 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -471,6 +471,7 @@ export function endpoint<
471
471
'handler' ,
472
472
) ;
473
473
methodDecorator ( cls . prototype , 'handler' , descriptor ) ;
474
+ Reflect . defineMetadata ( 'endpoints:path' , httpPath , cls ) ;
474
475
} ) ;
475
476
476
477
return cls ;
Original file line number Diff line number Diff line change @@ -42,17 +42,27 @@ export class EndpointsRouterModule {
42
42
rootDirectory = path . join ( path . dirname ( calledFrom ) , rootDirectory ) ;
43
43
}
44
44
settings . rootDirectory = rootDirectory ;
45
- const endpoints : Type [ ] = [ ] ;
45
+ let endpoints : Type [ ] = [ ] ;
46
46
if ( params . autoLoadEndpoints ?? true ) {
47
47
const endopointFiles = findEndpoints ( rootDirectory ) ;
48
48
for ( const f of endopointFiles ) {
49
49
// eslint-disable-next-line @typescript-eslint/no-require-imports
50
- endpoints . push ( require ( f ) . default ) ;
50
+ const endpoint = require ( f ) . default ;
51
+ if ( endpoint ) {
52
+ endpoints . push ( endpoint ) ;
53
+ }
51
54
}
52
55
}
53
56
for ( const fn of settings . decorateEndpointFns ) {
54
57
fn ( ) ;
55
58
}
59
+ if ( endpoints . length > 0 ) {
60
+ endpoints = endpoints . filter ( ( e ) => {
61
+ return Reflect . getMetadataKeys ( e ) . some (
62
+ ( k ) => k === 'endpoints:path' ,
63
+ ) ;
64
+ } ) ;
65
+ }
56
66
57
67
return {
58
68
module : EndpointsRouterModule ,
Original file line number Diff line number Diff line change 8
8
"scripts" : {
9
9
"build" : " rm -rf ./dist && pnpm tsc --project tsconfig.build.json" ,
10
10
"start" : " pnpm build && pnpm start:prod" ,
11
+ "start:dev" : " nest start --watch" ,
11
12
"start:prod" : " node dist/main" ,
12
13
"dev" : " tsx watch --inspect=0 --clear-screen=false ./src/main.ts" ,
13
14
"test:e2e" : " jest --config ./test/jest-e2e.json"
Original file line number Diff line number Diff line change @@ -9,9 +9,5 @@ echo '{"type": "commonjs"}' > dist/cjs/package.json
9
9
pnpm tsc --project tsconfig.esm.json && pnpm tsc-alias --project tsconfig.esm.json
10
10
echo ' {"type": "module"}' > dist/esm/package.json
11
11
# Modify the ESM router-module.js to use dynamic import instead of require
12
- if [[ " $OSTYPE " == " darwin" * ]]; then
13
- SED_OPTS=" -i ''"
14
- else
15
- SED_OPTS=" -i"
16
- fi
17
- sed $SED_OPTS ' s/require(f).default/await import(f).then((m) => m.default)/g' dist/esm/router-module.js
12
+ sed -i.bak ' s/require(f).default/await import(f).then((m) => m.default)/g' dist/esm/router-module.js
13
+ rm -f dist/esm/router-module.js.bak
You can’t perform that action at this time.
0 commit comments