Jerko Steiner 19565563cc Add Contextual<Service, Context> type
As seen in TeamService2.ts, the Contextual type will add Context as the
last argument to any method of the interface, as long as the method has
0-4 arguments.

Interfaces with more than 4 arguments cannot use this type, but they
could be converted to interfaces which use 1 argument
(object/dictionary) only.

Some long-term thinking: Maybe only methods with a single argument
should be supported, similar to the way gRPC does it.
2019-08-07 22:37:48 +07:00

48 lines
914 B
TypeScript

import {ITeam} from './ITeam'
import {IUserInTeam} from './IUserInTeam'
export interface ITeamAddUserParams {
teamId: number
userId: number
roleId: number
}
export interface ITeamCreateParams {
name: string
}
export interface ITeamRemoveParams {
id: number
}
export interface ITeamUpdateParams {
id: number
name: string
}
export interface IContext {
userId: number
}
export interface ITeamService {
jerko(params: string): number
create(params: ITeamCreateParams): Promise<ITeam>
remove(params: ITeamRemoveParams): Promise<{id: number}>
update(params: ITeamUpdateParams): Promise<ITeam>
addUser(params: ITeamAddUserParams): Promise<IUserInTeam>
removeUser(params: ITeamAddUserParams): Promise<ITeamAddUserParams>
findOne(id: number): Promise<ITeam | undefined>
find(): Promise<ITeam[]>
findUsers(teamId: number): Promise<IUserInTeam[]>
// TODO add other methods
}