本文整理汇总了TypeScript中acm类的典型用法代码示例。如果您正苦于以下问题:TypeScript acm类的具体用法?TypeScript acm怎么用?TypeScript acm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了acm类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: config
import * as imgur from 'imgur';
import * as config from 'acm';
const IMGUR_ALBUM_ID = config('files.avatars.imgur.album_id');
const IMGUR_CLIENT_ID = config('files.avatars.imgur.client_id');
const IMGUR_PASSWORD = config('files.avatars.imgur.password');
const IMGUR_USERNAME = config('files.avatars.imgur.username');
export namespace Model {
export interface Base {
id?: string;
link?: string;
}
export interface ImgurImage extends Base {
id: string;
link: string;
}
}
export namespace Payload {
export interface Base {
base64?: string;
}
export class ImgurImage implements Base {
base64: string;
constructor(base64: string) {
this.base64 = base64;
}
开发者ID:consumr-project,项目名称:cp,代码行数:31,代码来源:upload.ts
示例2: add
import { BadGatewayError, ERR_MSG_EXTERNAL_ERROR } from '../errors';
import * as config from 'acm';
import Trello = require('trello');
const TRELLO_KEY = config('trello.key');
const TRELLO_TOKEN = config('trello.token');
const TRELLO_LIST_ID = config('trello.list_id');
const TRELLO_BOARD_ID = config('trello.board_id');
export const trello = new Trello(TRELLO_KEY, TRELLO_TOKEN);
export namespace card {
export function add(name: string, desc: string) {
return trello.addCard(name, desc, TRELLO_LIST_ID)
.then(errw);
}
export function get(id: string) {
return trello.getCard(TRELLO_BOARD_ID, id)
.then(errw);
}
export function del(id: string) {
return trello.deleteCard(id)
.then(errw);
}
}
function errw(ack) {
if (typeof ack === 'string') {
开发者ID:consumr-project,项目名称:cp,代码行数:31,代码来源:trello.ts
示例3: recaptcha
import * as config from 'acm';
import * as request from 'request';
import { try_func } from '../utilities';
import { BadRequestError, BadGatewayError,
ERR_MSG_PARSING_ERROR } from '../errors';
const GOOGLE_RECAPTCHA_ENDPOINT = config('google.recaptcha.endpoint');
const GOOGLE_RECAPTCHA_SECRET = config('google.recaptcha.secret');
export function recaptcha(response: string, remoteip: string) {
return new Promise<boolean>((resolve, reject) => {
request({
method: 'POST',
uri: GOOGLE_RECAPTCHA_ENDPOINT,
formData: { response, remoteip,
secret: GOOGLE_RECAPTCHA_SECRET }
}, (err, res, body) => {
var [ parse_err, check ] = try_func(() => JSON.parse(body));
if (err) {
reject(err);
} else if (parse_err) {
reject(new BadGatewayError(ERR_MSG_PARSING_ERROR('google')));
} else if (!check.success) {
reject(new BadRequestError('failed to verify recaptcha'));
} else {
resolve(true);
}
});
});
}
开发者ID:consumr-project,项目名称:cp,代码行数:31,代码来源:recaptcha.ts
示例4: LinkDefinition
import db_connect, { DbmsDevice } from '../device/dbms';
import es_connect, { ElasticsearchDevice } from '../device/elasticsearch';
import { get, elasticsearch } from '../search/updater';
import { UpdaterAck, LinkConfiguration, LinkDefinition } from '../river/sync';
import { Duration } from '../lang';
import { logger } from '../log';
import { nonce } from '../crypto';
import * as config from 'acm';
import * as toes from '../toe';
const log = logger(__filename);
const models: LinkDefinition[] = config('river.models').map((def: LinkConfiguration) =>
new LinkDefinition(
def.name,
def.fields,
def.query_file,
def.soft_delete,
def.primary_key,
def.label));
export function run(since: Duration, identity: string, counter: number): Promise<UpdaterAck[]> {
var db: DbmsDevice;
var es: ElasticsearchDevice;
try {
db = db_connect();
es = es_connect();
models.map(model => log.info('river model entry', model));
return Promise.all(models.map(model => get(db, model, { since })
开发者ID:consumr-project,项目名称:cp,代码行数:31,代码来源:river.ts
示例5: if
app.use((err: any, req, res, next) => {
log.error('catching request handler error', err);
if (!res.headersSent) {
if (err instanceof HttpError || (isFinite(err.code) && err.name)) {
log.debug('sending back %s(%s)', err.name, err.code);
res.status(err.code);
} else if (err.code === 'ETIMEDOUT' || err.type === 'entity.too.large') {
log.debug('sending back Request Timeout(408)');
res.status(RequestTimeoutError.code);
} else {
log.debug('sending back generic 500');
res.status(500);
}
} else {
log.debug('headers already sent. no updates to response');
}
res.render('index', {
err,
cp_url: config('cp_url'),
debugging: CLIENT_DEBUG_INFO,
lang: normalize_i18n(req.query.lang),
});
});
开发者ID:consumr-project,项目名称:cp,代码行数:25,代码来源:main.ts
示例6: function
export default function (collection: string, cb: Function = () => {}) {
var url, env = process.env;
function send_back(err, conn, collection, cb) {
if (err) {
cb(err);
} else {
cb(null, conn.collection(collection));
}
}
if (connection) {
send_back(connection_err, connection, collection, cb);
} else {
log.info('connecting to mongodb');
url = !env.MONGO_HOST ? config('mongo.url') :
'mongodb://' + env.MONGO_HOST + ':27017/' + env.MONGO_COLLECTION;
MongoClient.connect(url, (err, db) => {
connection = db;
connection_err = err;
if (err) {
log.error('error connecting to mongo', err);
} else {
log.info('connected to mongodb');
}
send_back(connection_err, connection, collection, cb);
});
}
}
开发者ID:consumr-project,项目名称:cp,代码行数:32,代码来源:mongo.ts
示例7: generate_body
function generate_body(template: EMAIL, payload: PAYLOAD, lang: string) {
var data = {
body: '',
payload: payload,
images: ASSETS.images,
styles: ASSETS.styles,
i18n: pick_i18n(lang),
config: {
url: config('cp.url'),
}
};
data.body = TEMPLATES[template](data);
return TEMPLATES.base(data);
}
开发者ID:consumr-project,项目名称:cp,代码行数:15,代码来源:email.ts
示例8: get_event_and_act_upon_message
InternalServerError, ERR_MSG_MISSING_FIELDS } from '../errors';
import Message, { CATEGORY, NOTIFICATION, OTYPE } from '../notification/message';
import { save, find, purge, update, purge_signature } from '../repository/notification';
import { head } from 'lodash';
import connect from '../device/mongo';
export const router = Router();
router.use((req, res, next) => {
// 5 minute caching
res.setHeader('Cache-Control', `private, max-age=${minutes(5) / 1000}`);
next();
});
connect(config('mongo.collections.notifications'), (err, coll) => {
function get_event_and_act_upon_message(id: string, action: Function, processor: (ev: EventMessage) => Message) {
// XXX check this isn't our own event
return new Promise<Message | DeleteWriteOpResultObject>((resolve, reject) =>
Event.findById(id)
.then((ev: EventMessage) => {
var msg = processor(ev);
msg.sign();
action(coll, action === purge_signature ? msg.signature : msg)
.then(ack => resolve(msg))
.catch(err => reject(new InternalServerError(err.message)));
})
.catch(err => reject(new InternalServerError(err.message))));
}
开发者ID:consumr-project,项目名称:cp,代码行数:30,代码来源:notification.ts
示例9: do_log
function do_log() {
if (config('logging.enable.sql')) {
return log.debug.apply(log, arguments);
}
}
开发者ID:consumr-project,项目名称:cp,代码行数:5,代码来源:dbms.ts
示例10: config
})).catch(err => res.render('index', {
unfurled: OG,
cp_url: config('cp_url'),
debugging: CLIENT_DEBUG_INFO,
lang: normalize_i18n(req.query.lang),
}));
开发者ID:consumr-project,项目名称:cp,代码行数:6,代码来源:main.ts
注:本文中的acm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论