-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,405 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"printWidth": 200 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import {TestAccount} from '../models/account'; | ||
import {Route, Get} from 'tsoa'; | ||
import {User} from '../models/user'; | ||
import { Get, Route } from 'tsoa'; | ||
import { TestAccount } from '../models/account'; | ||
import { User } from '../models/user'; | ||
|
||
@Route('Accounts') | ||
export class AccountsController { | ||
/** Get the current account */ | ||
@Get('Current') | ||
public async current(): Promise<TestAccount> { | ||
return { | ||
id: 600, | ||
name: 'test' | ||
}; | ||
} | ||
/** Get the current account */ | ||
@Get('Current') | ||
public async current(): Promise<TestAccount> { | ||
return { | ||
id: 600, | ||
name: 'test', | ||
}; | ||
} | ||
|
||
/** Get a list of users for the account */ | ||
@Get('Users') | ||
public async getUsers(): Promise<User[]> { | ||
return [ | ||
{ | ||
createdAt: new Date(), | ||
email: '[email protected]', | ||
id: 1 | ||
}, | ||
{ | ||
createdAt: new Date(), | ||
email: '[email protected]', | ||
id: 2, | ||
} | ||
]; | ||
} | ||
/** Get a list of users for the account */ | ||
@Get('Users') | ||
public async getUsers(): Promise<User[]> { | ||
return [ | ||
{ | ||
createdAt: new Date(), | ||
email: '[email protected]', | ||
id: 1, | ||
}, | ||
{ | ||
createdAt: new Date(), | ||
email: '[email protected]', | ||
id: 2, | ||
}, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,59 @@ | ||
import {Route, Get, Post, Delete, Patch, Example, Body} from 'tsoa'; | ||
import {User, UserCreateRequest, UserUpdateRequest} from '../models/user'; | ||
import { Body, Delete, Example, Get, Patch, Post, Route } from 'tsoa'; | ||
import { User, UserCreateRequest, UserUpdateRequest } from '../models/user'; | ||
|
||
@Route('Users') | ||
export class UsersController { | ||
/** Get the current user */ | ||
@Get('Current') | ||
@Example<User>({ | ||
createdAt: new Date(), | ||
email: '[email protected]', | ||
id: 1, | ||
}) | ||
public async Current(): Promise<User> { | ||
return { | ||
createdAt: new Date(), | ||
email: 'test', | ||
id: 666, | ||
}; | ||
} | ||
|
||
/** Get the current user */ | ||
@Get('Current') | ||
@Example<User>({ | ||
createdAt: new Date(), | ||
email: '[email protected]', | ||
id: 1, | ||
}) | ||
public async Current(): Promise<User> { | ||
return { | ||
createdAt: new Date(), | ||
email: 'test', | ||
id: 666 | ||
}; | ||
} | ||
/** Get user by ID */ | ||
@Get('{userId}') | ||
public async Get(userId: number): Promise<User> { | ||
return { | ||
createdAt: new Date(), | ||
email: 'test2', | ||
id: userId, | ||
}; | ||
} | ||
|
||
/** Get user by ID */ | ||
@Get('{userId}') | ||
public async Get(userId: number): Promise<User> { | ||
return { | ||
createdAt: new Date(), | ||
email: 'test2', | ||
id: userId | ||
}; | ||
} | ||
/** | ||
* Create a user | ||
* @param request This is a user creation request description | ||
*/ | ||
@Post() | ||
public async Create(@Body() request: UserCreateRequest): Promise<User> { | ||
return { | ||
createdAt: new Date(), | ||
email: request.email, | ||
id: 666, | ||
}; | ||
} | ||
|
||
/** | ||
* Create a user | ||
* @param request This is a user creation request description | ||
*/ | ||
@Post() | ||
public async Create(@Body() request: UserCreateRequest): Promise<User> { | ||
return { | ||
createdAt: new Date(), | ||
email: request.email, | ||
id: 666 | ||
}; | ||
} | ||
/** Delete a user by ID */ | ||
@Delete('{userId}') | ||
public async Delete(userId: number): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
/** Delete a user by ID */ | ||
@Delete('{userId}') | ||
public async Delete(userId: number): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
/** Update a user */ | ||
@Patch() | ||
public async Update(@Body() request: UserUpdateRequest): Promise<User> { | ||
return { | ||
createdAt: request.createdAt, | ||
email: request.email, | ||
id: 1337 | ||
}; | ||
} | ||
/** Update a user */ | ||
@Patch() | ||
public async Update(@Body() request: UserUpdateRequest): Promise<User> { | ||
return { | ||
createdAt: request.createdAt, | ||
email: request.email, | ||
id: 1337, | ||
}; | ||
} | ||
} |
Oops, something went wrong.