本文整理汇总了TypeScript中decentraland-server.server类的典型用法代码示例。如果您正苦于以下问题:TypeScript server类的具体用法?TypeScript server怎么用?TypeScript server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了server类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: mount
mount() {
/**
* Returns all polls
*/
this.app.get('/polls', server.handleRequest(this.getPolls))
/**
* Return a poll by id
* @param {string} id
*/
this.app.get('/polls/:id', server.handleRequest(this.getPoll))
}
示例2: getString
function getString(req: Request, param: string, defaultValue: any = null) {
try {
return server.extractFromReq(req, param)
} catch (error) {
return defaultValue
}
}
示例3: mount
mount() {
/**
* Returns a full vote by id
*/
this.app.get('/votes/:id', server.handleRequest(this.getVote))
/**
* Returns the votes for a poll
*/
this.app.get('/polls/:id/votes', server.handleRequest(this.getPollVotes))
/**
* Creates a new vote, returns the new id
*/
this.app.post('/votes', server.handleRequest(this.createVote))
}
示例4: mount
mount() {
/**
* Returns the votes for a poll
*/
this.app.get(
'/accountBalances/:address',
server.handleRequest(this.getAccountBalances)
)
}
示例5: mount
mount() {
/**
* Returns all receipts
*/
this.app.get('/receipts', server.handleRequest(this.getReceipts))
/**
* Returns a receipt by id
*/
this.app.get('/receipts/:id', server.handleRequest(this.getReceipt))
/**
* Returns account receipts
*/
this.app.get(
'/accounts/:address/receipts',
server.handleRequest(this.getAccountReceipts)
)
}
示例6: mount
mount() {
/**
* Returns the translations for a given locale
* @param {string} locale - locale name
* @return {array<Translation>}
*/
this.app.get(
'/translations/:locale',
server.handleRequest(this.getTranslations)
)
}
示例7: getTranslations
async getTranslations(req: express.Request): Promise<TranslationData> {
let locale = server.extractFromReq(req, 'locale')
locale = locale.slice(0, 2) // We support base locales for now, like en, it, etc
return new Translation().fetch(locale)
}
示例8: getPollVotes
async getPollVotes(req: express.Request) {
const pollId = server.extractFromReq(req, 'id')
return Vote.find({ poll_id: pollId })
}
示例9: mount
mount() {
/**
* Returns the votes for a poll
*/
this.app.get('/polls/:id/options', server.handleRequest(this.getPollVotes))
}
示例10: getPollVotes
async getPollVotes(req: express.Request) {
const pollId = server.extractFromReq(req, 'id')
return Option.find<OptionAttributes>({ poll_id: Number(pollId) })
}