File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,4 +121,35 @@ export class MakeCommand {
121121 . cd ( subdir )
122122 . render ( 'service.empty.ts' , `${ names . kebabName } .service.ts` , names )
123123 }
124+
125+ @Command ( {
126+ name : 'make:filter <name>' ,
127+ description : 'Create a HTTP exception filter.' ,
128+ arguments : {
129+ name : 'Filter class name.' ,
130+ } ,
131+ } )
132+ async filter (
133+ @Arguments ( )
134+ args : string [ ]
135+ ) {
136+ const [ name ] = args
137+
138+ const fs = new FileSystem ( )
139+
140+ let root = ''
141+ if ( fs . exists ( 'app/filters' ) ) {
142+ root = 'app/filters'
143+ } else if ( fs . exists ( 'filters' ) ) {
144+ root = 'filters'
145+ }
146+
147+ const names = getNames ( basename ( name ) )
148+ const subdir = dirname ( name )
149+
150+ fs . cd ( root )
151+ . ensureDir ( subdir )
152+ . cd ( subdir )
153+ . render ( 'filter.empty.ts' , `${ names . kebabName } .exception.filter.ts` , names )
154+ }
124155}
Original file line number Diff line number Diff line change 1+ import { Catch , ExceptionFilter } from "@smoothjs/smooth" ;
2+
3+ @Catch ( )
4+ export class /* upperFirstCamelName */ implements ExceptionFilter {
5+ async catch (
6+ exception : any ,
7+ response : any ,
8+ ) {
9+ response . send ( 'Hello World' )
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments