Update controller boilerplate

This commit is contained in:
Tobe O 2018-07-14 19:18:53 -04:00
parent 7d6884bd8d
commit d7038c7c68

View file

@ -26,7 +26,7 @@ class ControllerCommand extends Command {
abbr: 'n', help: 'Specifies a name for the model class.') abbr: 'n', help: 'Specifies a name for the model class.')
..addOption('output-dir', ..addOption('output-dir',
help: 'Specifies a directory to create the controller class in.', help: 'Specifies a directory to create the controller class in.',
defaultsTo: 'lib/src/controllers'); defaultsTo: 'lib/src/routes/controllers');
} }
@override @override
@ -69,7 +69,7 @@ class ControllerCommand extends Command {
..name = 'hello' ..name = 'hello'
..returns = refer('void') ..returns = refer('void')
..annotations.add(refer('ExposeWs') ..annotations.add(refer('ExposeWs')
.constInstance([literal('get_${rc.snakeCase}')])) .newInstance([literal('get_${rc.snakeCase}')]))
..requiredParameters.add(new Parameter((b) => b ..requiredParameters.add(new Parameter((b) => b
..name = 'socket' ..name = 'socket'
..type = refer('WebSocketContext'))) ..type = refer('WebSocketContext')))
@ -82,14 +82,14 @@ class ControllerCommand extends Command {
})); }));
} else { } else {
clazz clazz
..annotations.add( ..annotations
refer('Expose').constInstance([literal('/${rc.snakeCase}')])) .add(refer('Expose').newInstance([literal('/${rc.snakeCase}')]))
..methods.add(new Method((meth) { ..methods.add(new Method((meth) {
meth meth
..name = 'hello' ..name = 'hello'
..returns = refer('String') ..returns = refer('String')
..body = literal('Hello, world').returned.statement ..body = literal('Hello, world').returned.statement
..annotations.add(refer('Expose').constInstance([ ..annotations.add(refer('Expose').newInstance([
literal('/'), literal('/'),
])); ]));
})); }));