本文整理匯總了TypeScript中@nestjs/common.Get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Get函數的具體用法?TypeScript Get怎麽用?TypeScript Get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Get函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: index
@Get()
index() {
return {
status: 'OK',
v: 4
};
}
示例2: multicats
@Get('broadcast')
multicats() {
return this.client.send<number>({ cmd: 'broadcast' }, {})
.pipe(
scan((a, b) => a + b),
take(2),
);
}
示例3: call
@Get()
call(): Observable<string> {
//呼叫使用一個策略,選定sayHi
const pattern = { cmd: 'sayHi' };
//由於send()要傳入兩個參數,pattern 和 data,data這邊給定空字串。
const data = '';
return this.client.send<string>(pattern, data);
}
示例4: root
@ApiOperation({ title: 'Root of api', description: 'Just fetches the name and version' })
@ApiResponse({ status: 200, description: 'If the server is up and running' })
@Get()
root(): any {
return {
name: pkg.name,
version: pkg.version
};
}
示例5: UserEntity
@Get()
findOne(): UserEntity {
return new UserEntity({
id: 1,
firstName: 'Kamil',
lastName: 'Mysliwiec',
password: 'password',
role: new RoleEntity({ id: 1, name: 'admin' }),
});
}
示例6: root
@Get()
async root() {
const model: MarketAccount = await this.marketAccountService.findOne(1);
const exchange: Exchange = model.exchange;
if (exchange !== Exchange.gateio) {
model.exchange = Exchange.gateio;
}
return await model.save();
}
示例7: callRabbitMQ
@Get('/rabbitMQ')
callRabbitMQ(): Observable<string> {
//呼叫使用一個策略,選定amqp
const pattern = { cmd: 'amqp' };
//send()要傳入兩個參數,pattern 和 data,pattern選擇哪種策略,data則是要傳遞的訊息。
const data = 'use RabbitMQ';
//透過RabbitMQ消息隊列方式傳遞訊息,注意queue要跟server.ts建立的RabbitMQServer的queue一樣
this.client = new RabbitMQClient('amqp://rmtahlzz:Jqyq1OnzF7qWPzQXmcwAQly_aRsTrd1z@mustang.rmq.cloudamqp.com/rmtahlzz', 'example');
return this.client.send<string>(pattern, data);
}
示例8: findAll
@Get()
findAll(): Promise<Photo[]> {
return this.photoService.findAll();
}
示例9: createToken
@Get('token')
async createToken(): Promise<any> {
return await this.authService.createToken();
}
示例10: findAll
@Get('data')
@UseGuards(AuthGuard('jwt'))
findAll() {
// this route is restricted
return [];
}