@nodeswork/applet
Version:
Nodeswork Applet Framework
53 lines (51 loc) • 2.21 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const _ = require("underscore");
const Router = require("koa-router");
const kiws_1 = require("@nodeswork/kiws");
const ACCOUNT_TYPES = [
{
accountType: 'OAuthAccount',
provider: 'twitter',
type: 'TwitterAccount',
},
];
let AccountInputProvider = class AccountInputProvider {
getAccounts(ctx) {
const accounts = ctx.request.body.accounts;
const inputs = _
.chain(accounts)
.map((account) => {
let type = _.find(ACCOUNT_TYPES, (accountType) => {
return account.accountType === accountType.accountType &&
account.provider === accountType.provider;
});
return type != null ?
{ type: type && type.type, data: account } :
{ type: account.accountType, data: account };
})
.filter((input) => input.type != null)
.value();
return inputs;
}
};
__decorate([
kiws_1.InputGenerator(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Array)
], AccountInputProvider.prototype, "getAccounts", null);
AccountInputProvider = __decorate([
kiws_1.InputProvider({})
], AccountInputProvider);
exports.AccountInputProvider = AccountInputProvider;
//# sourceMappingURL=account.input.provider.js.map