@yopdev/dev-server 1.3.1 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,7 +66,7 @@ var EventsProxy = /** @class */ (function () {
66
66
  }); };
67
67
  this.queueConnectedToTopic = function (sns, topic, sqs, queue) { return __awaiter(_this, void 0, void 0, function () {
68
68
  return __generator(this, function (_a) {
69
- return [2 /*return*/, sqs.createNamedQueue(queue)
69
+ return [2 /*return*/, sqs.createStandardQueue(queue)
70
70
  .then(function (queue) { return sns
71
71
  .createSubscription({ arn: topic }, { arn: queue.arn })
72
72
  .then(function () { return queue.url; }); })];
@@ -5,4 +5,5 @@ export declare const newInternalQueue: (name: string, config: {
5
5
  index: number;
6
6
  visibility: number;
7
7
  handler: (queue: Queue) => (e: SQSEvent) => Promise<void>;
8
+ fifo: boolean;
8
9
  }, callback?: Callback<string>) => Service<string>;
@@ -42,14 +42,15 @@ var sqs_consumer_1 = require("sqs-consumer");
42
42
  var stoppable_1 = require("./stoppable");
43
43
  var mappers_1 = require("./mappers");
44
44
  var services_1 = require("./services");
45
- var newInternalQueue = function (name, config, callback) { return new services_1.Service(new InternalQueue(name, config.visibility, config.handler, config.index), callback); };
45
+ var newInternalQueue = function (name, config, callback) { return new services_1.Service(new InternalQueue(name, config.visibility, config.handler, config.index, function (sqs) { return config.fifo ? sqs.createFifoQueue : sqs.createStandardQueue; }), callback); };
46
46
  exports.newInternalQueue = newInternalQueue;
47
47
  var InternalQueue = /** @class */ (function () {
48
- function InternalQueue(name, visibility, handler, index) {
48
+ function InternalQueue(name, visibility, handler, index, creator) {
49
49
  var _this = this;
50
50
  this.name = name;
51
51
  this.visibility = visibility;
52
52
  this.handler = handler;
53
+ this.creator = creator;
53
54
  this.start = function (config) { return _this.create(config.sqs); };
54
55
  this.create = function (sqs) { return __awaiter(_this, void 0, void 0, function () {
55
56
  var _this = this;
@@ -97,8 +98,7 @@ var InternalQueue = /** @class */ (function () {
97
98
  return __awaiter(this, void 0, void 0, function () {
98
99
  var _this = this;
99
100
  return __generator(this, function (_a) {
100
- return [2 /*return*/, sqs
101
- .createNamedQueue(name) //
101
+ return [2 /*return*/, this.creator(sqs)(name) //
102
102
  .then(function (queue) {
103
103
  _this.LOGGER.info('created: %s', queue.url);
104
104
  return queue;
@@ -1,11 +1,2 @@
1
- import { Lifecycle, Service, Callback } from './services';
2
- export declare const newPreTrafficHooks: (name: string, hooks: () => Promise<void>[], callback?: Callback<PreTrafficHooks>) => Service<PreTrafficHooks>;
3
- declare class PreTrafficHooks implements Lifecycle<PreTrafficHooks> {
4
- readonly name: string;
5
- private readonly hooks;
6
- private LOGGER;
7
- constructor(name: string, hooks: () => Promise<void>[]);
8
- start: () => Promise<this>;
9
- stop: () => Promise<void>;
10
- }
11
- export {};
1
+ import { Service } from './services';
2
+ export declare const newPreTrafficHooks: (name: string, hooks: () => Promise<void>[]) => Service<any>;
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.newPreTrafficHooks = void 0;
40
40
  var logging_1 = require("@yopdev/logging");
41
41
  var services_1 = require("./services");
42
- var newPreTrafficHooks = function (name, hooks, callback) { return new services_1.Service(new PreTrafficHooks(name, hooks), callback); };
42
+ var newPreTrafficHooks = function (name, hooks) { return new services_1.Service(new PreTrafficHooks(name, hooks)); };
43
43
  exports.newPreTrafficHooks = newPreTrafficHooks;
44
44
  var PreTrafficHooks = /** @class */ (function () {
45
45
  function PreTrafficHooks(name, hooks) {
@@ -47,11 +47,10 @@ var PreTrafficHooks = /** @class */ (function () {
47
47
  this.name = name;
48
48
  this.hooks = hooks;
49
49
  this.start = function () { return __awaiter(_this, void 0, void 0, function () {
50
- var _this = this;
51
50
  return __generator(this, function (_a) {
52
51
  return [2 /*return*/, Promise
53
52
  .all(this.hooks())
54
- .then(function () { return _this; })];
53
+ .then(function () { return undefined; })];
55
54
  });
56
55
  }); };
57
56
  this.stop = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
package/dist/src/s3.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { S3Client } from '@aws-sdk/client-s3';
1
+ import { CORSConfiguration, S3Client } from '@aws-sdk/client-s3';
2
2
  import { AwsConfig } from './config';
3
3
  export declare class S3 {
4
4
  readonly client: S3Client;
5
5
  constructor(aws: AwsConfig);
6
- createBucket: (name: string) => Promise<import("@aws-sdk/client-s3").CreateBucketCommandOutput>;
6
+ createBucket: (name: string, cors?: CORSConfiguration) => Promise<import("@aws-sdk/client-s3").PutBucketCorsCommandOutput>;
7
7
  }
package/dist/src/s3.js CHANGED
@@ -54,11 +54,16 @@ var LOGGER = logging_1.LoggerFactory.create('S3');
54
54
  var S3 = /** @class */ (function () {
55
55
  function S3(aws) {
56
56
  var _this = this;
57
- this.createBucket = function (name) { return __awaiter(_this, void 0, void 0, function () {
57
+ this.createBucket = function (name, cors) { return __awaiter(_this, void 0, void 0, function () {
58
+ var _this = this;
58
59
  return __generator(this, function (_a) {
59
60
  return [2 /*return*/, this.client.send(new client_s3_1.CreateBucketCommand({
60
61
  Bucket: name,
61
62
  }))
63
+ .then(function () { return cors && _this.client.send(new client_s3_1.PutBucketCorsCommand({
64
+ Bucket: name,
65
+ CORSConfiguration: cors
66
+ })); })
62
67
  .tap(function () { return LOGGER.debug('bucket %s created', name); })];
63
68
  });
64
69
  }); };
package/dist/src/sqs.d.ts CHANGED
@@ -3,7 +3,9 @@ import { AwsConfig } from "./config";
3
3
  export declare class Sqs {
4
4
  readonly client: SQSClient;
5
5
  constructor(config: AwsConfig);
6
- createNamedQueue: (name: string) => Promise<Queue>;
6
+ createStandardQueue: (name: string) => Promise<Queue>;
7
+ createFifoQueue: (name: string) => Promise<Queue>;
8
+ private createNamedQueue;
7
9
  }
8
10
  export type Queue = {
9
11
  arn: string;
package/dist/src/sqs.js CHANGED
@@ -45,12 +45,21 @@ var LOGGER = logging_1.LoggerFactory.create('SQS');
45
45
  var Sqs = /** @class */ (function () {
46
46
  function Sqs(config) {
47
47
  var _this = this;
48
- this.createNamedQueue = function (name) { return __awaiter(_this, void 0, void 0, function () {
48
+ this.createStandardQueue = function (name) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
49
+ return [2 /*return*/, this.createNamedQueue(name, false)];
50
+ }); }); };
51
+ this.createFifoQueue = function (name) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
52
+ return [2 /*return*/, this.createNamedQueue(name, true)];
53
+ }); }); };
54
+ this.createNamedQueue = function (name, fifo) { return __awaiter(_this, void 0, void 0, function () {
49
55
  var _this = this;
50
56
  return __generator(this, function (_a) {
51
57
  return [2 /*return*/, this.client
52
58
  .send(new client_sqs_1.CreateQueueCommand({
53
- QueueName: name,
59
+ QueueName: fifo ? "".concat(name, ".fifo") : name,
60
+ Attributes: {
61
+ FifoQueue: fifo ? 'true' : 'false',
62
+ }
54
63
  }))
55
64
  .then(function (create) { return _this.client
56
65
  .send(new client_sqs_1.GetQueueAttributesCommand({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yopdev/dev-server",
3
- "version": "1.3.1",
3
+ "version": "1.3.8",
4
4
  "scripts": {
5
5
  "compile": "tsc",
6
6
  "pretest": "npm run compile",