@lomray/microservice-payment-stripe
Version:
Stripe payment microservice based on NodeJS & inverted json.
56 lines (52 loc) • 1.81 kB
JavaScript
;
var tslib = require('tslib');
var microserviceHelpers = require('@lomray/microservice-helpers');
var classTransformer = require('class-transformer');
var classValidator = require('class-validator');
var product = require('../../entities/product.js');
var stripe = require('../../services/payment-gateway/stripe.js');
class ProductCreateInput {
}
tslib.__decorate([
classValidator.IsString(),
tslib.__metadata("design:type", String)
], ProductCreateInput.prototype, "entityId", void 0);
tslib.__decorate([
classValidator.IsString(),
tslib.__metadata("design:type", String)
], ProductCreateInput.prototype, "name", void 0);
tslib.__decorate([
classValidator.IsString(),
tslib.__metadata("design:type", String)
], ProductCreateInput.prototype, "userId", void 0);
tslib.__decorate([
classValidator.IsString(),
microserviceHelpers.IsUndefinable(),
tslib.__metadata("design:type", String)
], ProductCreateInput.prototype, "description", void 0);
tslib.__decorate([
classValidator.IsArray(),
microserviceHelpers.IsUndefinable(),
tslib.__metadata("design:type", Array)
], ProductCreateInput.prototype, "images", void 0);
class ProductCreateOutput {
}
tslib.__decorate([
classValidator.IsObject(),
classTransformer.Type(() => product),
tslib.__metadata("design:type", product)
], ProductCreateOutput.prototype, "entity", void 0);
/**
* Create new product
*/
const create = microserviceHelpers.Endpoint.custom(() => ({
input: ProductCreateInput,
output: ProductCreateOutput,
description: 'Create new product',
}), (params) => tslib.__awaiter(void 0, void 0, void 0, function* () {
const service = yield stripe.init();
return {
entity: yield service.createProduct(params),
};
}));
module.exports = create;