Skip to content

Commit 03ef22b

Browse files
committed
Improvements in templates related to feature 0.5.1
1 parent 8326753 commit 03ef22b

8 files changed

Lines changed: 51 additions & 4 deletions

File tree

src/stages/CreatePackageJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const createPackageJson = (target: string, name: string) => {
1111
build: 'tsc -p .'
1212
},
1313
dependencies: {
14-
recife: '^0.4.0',
14+
recife: '^0.5.0',
1515
typescript: '^3.*'
1616
},
1717
browserslist: {

templates/project/config/app.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { AppConfig } from 'recife';
2+
3+
export const config: AppConfig = {
4+
appName: 'APP_NAME',
5+
basePath: 'src',
6+
port: 8100,
7+
host: 'localhost'
8+
};
File renamed without changes.

templates/project/src/controllers/UserController.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
import { Query, Mutation } from 'recife';
22

33
import UserModel from '../models/UserModel';
4+
import AddressModel from '../models/AddressModel';
45
import { UserForm, UserDelete } from '../inputs/UserInput';
56

67
class UserController {
8+
addressDefault: AddressModel;
9+
10+
constructor() {
11+
this.addressDefault = new AddressModel(
12+
'Av. Alfredo Lisboa',
13+
'Recife',
14+
'Pernambuco',
15+
'50020360'
16+
);
17+
}
18+
719
@Query()
820
getUser(): UserModel {
921
const user = new UserModel();
1022
user.name = 'Quaco Cainr';
1123
user.email = 'quacocainr@email.com';
1224
user.username = 'quacocainr';
25+
user.address = this.addressDefault;
1326

1427
return user;
1528
}
@@ -20,6 +33,7 @@ class UserController {
2033
user.name = input.name;
2134
user.email = input.email;
2235
user.username = input.username;
36+
user.address = this.addressDefault;
2337

2438
return user;
2539
}
@@ -30,6 +44,7 @@ class UserController {
3044
user.name = input.name;
3145
user.email = input.email;
3246
user.username = input.username;
47+
user.address = this.addressDefault;
3348

3449
return user;
3550
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Type } from 'recife';
2+
3+
@Type()
4+
class AddressModel {
5+
street: string;
6+
city: string;
7+
state: string;
8+
zipCode: string;
9+
10+
constructor(street: string, city: string, state: string, zipCode: string) {
11+
this.street = street;
12+
this.city = city;
13+
this.state = state;
14+
this.zipCode = zipCode;
15+
}
16+
}
17+
18+
export default AddressModel;
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { Type } from 'recife';
2+
import AddressModel from './AddressModel';
23

34
@Type()
45
class UserModel {
5-
name!: String;
6-
email!: String;
7-
username!: String;
6+
name?: string;
7+
email?: string;
8+
username?: string;
9+
address?: AddressModel;
10+
11+
static getAddress(user: UserModel) {
12+
return user.address;
13+
}
814
}
915

1016
export default UserModel;

0 commit comments

Comments
 (0)