typespeed 2.0.21 → 2.0.23

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.
Files changed (219) hide show
  1. package/dist/core.decorator.js +1 -30
  2. package/dist/default/default-authentication.class.js +25 -0
  3. package/dist/default/express-server.class.js +11 -4
  4. package/dist/default/log-default.class.js +0 -6
  5. package/dist/factory/authentication-factory.class.js +11 -0
  6. package/dist/factory/log-factory.class.js +9 -0
  7. package/dist/route.decorator.js +92 -2
  8. package/dist/typespeed.d.ts +40 -3
  9. package/dist/typespeed.js +3 -1
  10. package/package.json +1 -1
  11. package/src/core.decorator.ts +1 -29
  12. package/src/default/default-authentication.class.ts +10 -0
  13. package/src/default/express-server.class.ts +12 -5
  14. package/src/default/log-default.class.ts +0 -10
  15. package/src/factory/authentication-factory.class.ts +9 -0
  16. package/src/factory/log-factory.class.ts +9 -2
  17. package/src/route.decorator.ts +91 -3
  18. package/src/typespeed.d.ts +40 -3
  19. package/src/typespeed.ts +1 -0
  20. package/test/node_modules/.package-lock.json +65 -101
  21. package/test/node_modules/@types/body-parser/LICENSE +21 -0
  22. package/test/node_modules/@types/body-parser/README.md +16 -0
  23. package/test/node_modules/@types/body-parser/index.d.ts +107 -0
  24. package/test/node_modules/@types/body-parser/package.json +58 -0
  25. package/test/node_modules/@types/connect/LICENSE +21 -0
  26. package/test/node_modules/@types/connect/README.md +16 -0
  27. package/test/node_modules/@types/connect/index.d.ts +93 -0
  28. package/test/node_modules/@types/connect/package.json +32 -0
  29. package/test/node_modules/@types/express/LICENSE +21 -0
  30. package/test/node_modules/@types/express/README.md +16 -0
  31. package/test/node_modules/@types/express/index.d.ts +136 -0
  32. package/test/node_modules/@types/express/package.json +45 -0
  33. package/test/node_modules/@types/express-serve-static-core/LICENSE +21 -0
  34. package/test/node_modules/@types/express-serve-static-core/README.md +16 -0
  35. package/test/node_modules/@types/express-serve-static-core/index.d.ts +1281 -0
  36. package/test/node_modules/@types/express-serve-static-core/package.json +55 -0
  37. package/test/node_modules/@types/mime/LICENSE +21 -0
  38. package/test/node_modules/@types/mime/Mime.d.ts +10 -0
  39. package/test/node_modules/@types/mime/README.md +16 -0
  40. package/test/node_modules/@types/mime/index.d.ts +35 -0
  41. package/test/node_modules/@types/mime/lite.d.ts +7 -0
  42. package/test/node_modules/@types/mime/package.json +29 -0
  43. package/test/node_modules/@types/qs/LICENSE +21 -0
  44. package/test/node_modules/@types/qs/README.md +16 -0
  45. package/test/node_modules/@types/qs/index.d.ts +62 -0
  46. package/test/node_modules/@types/qs/package.json +65 -0
  47. package/test/node_modules/@types/range-parser/LICENSE +21 -0
  48. package/test/node_modules/@types/range-parser/README.md +55 -0
  49. package/test/node_modules/@types/range-parser/index.d.ts +35 -0
  50. package/test/node_modules/@types/range-parser/package.json +25 -0
  51. package/test/node_modules/@types/send/LICENSE +21 -0
  52. package/test/node_modules/@types/send/README.md +16 -0
  53. package/test/node_modules/@types/send/index.d.ts +231 -0
  54. package/test/node_modules/@types/send/package.json +33 -0
  55. package/test/node_modules/@types/serve-static/LICENSE +21 -0
  56. package/test/node_modules/@types/serve-static/README.md +16 -0
  57. package/test/node_modules/@types/serve-static/index.d.ts +113 -0
  58. package/test/node_modules/@types/serve-static/package.json +38 -0
  59. package/test/src/config.json +5 -0
  60. package/test/src/custom-log.class.ts +6 -0
  61. package/test/src/jwt-authentication.class.ts +29 -0
  62. package/test/src/test-request.class.ts +36 -0
  63. package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-ci.yml +0 -17
  64. package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-publish.yml +0 -30
  65. package/test/node_modules/@acuminous/bitsyntax/LICENSE +0 -6
  66. package/test/node_modules/@acuminous/bitsyntax/LICENSE-MIT +0 -21
  67. package/test/node_modules/@acuminous/bitsyntax/Makefile +0 -15
  68. package/test/node_modules/@acuminous/bitsyntax/README.md +0 -308
  69. package/test/node_modules/@acuminous/bitsyntax/index.js +0 -10
  70. package/test/node_modules/@acuminous/bitsyntax/lib/compile.js +0 -303
  71. package/test/node_modules/@acuminous/bitsyntax/lib/constructor.js +0 -142
  72. package/test/node_modules/@acuminous/bitsyntax/lib/grammar.pegjs +0 -67
  73. package/test/node_modules/@acuminous/bitsyntax/lib/interp.js +0 -232
  74. package/test/node_modules/@acuminous/bitsyntax/lib/parse.js +0 -32
  75. package/test/node_modules/@acuminous/bitsyntax/lib/parser.js +0 -1173
  76. package/test/node_modules/@acuminous/bitsyntax/lib/pattern.js +0 -119
  77. package/test/node_modules/@acuminous/bitsyntax/package.json +0 -36
  78. package/test/node_modules/@acuminous/bitsyntax/test/consing.test.js +0 -50
  79. package/test/node_modules/@acuminous/bitsyntax/test/matching.test.js +0 -193
  80. package/test/node_modules/amqplib/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  81. package/test/node_modules/amqplib/.github/workflows/test.yml +0 -38
  82. package/test/node_modules/amqplib/CHANGELOG.md +0 -430
  83. package/test/node_modules/amqplib/LICENSE +0 -6
  84. package/test/node_modules/amqplib/LICENSE-MIT +0 -21
  85. package/test/node_modules/amqplib/Makefile +0 -47
  86. package/test/node_modules/amqplib/README.md +0 -157
  87. package/test/node_modules/amqplib/bin/generate-defs.js +0 -722
  88. package/test/node_modules/amqplib/callback_api.js +0 -22
  89. package/test/node_modules/amqplib/channel_api.js +0 -16
  90. package/test/node_modules/amqplib/examples/headers.js +0 -42
  91. package/test/node_modules/amqplib/examples/receive_generator.js +0 -39
  92. package/test/node_modules/amqplib/examples/send_generators.js +0 -42
  93. package/test/node_modules/amqplib/examples/ssl.js +0 -64
  94. package/test/node_modules/amqplib/examples/tutorials/README.md +0 -93
  95. package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log.js +0 -28
  96. package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_direct.js +0 -30
  97. package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_topic.js +0 -27
  98. package/test/node_modules/amqplib/examples/tutorials/callback_api/new_task.js +0 -27
  99. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive.js +0 -30
  100. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs.js +0 -36
  101. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_direct.js +0 -56
  102. package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_topic.js +0 -55
  103. package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_client.js +0 -49
  104. package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_server.js +0 -45
  105. package/test/node_modules/amqplib/examples/tutorials/callback_api/send.js +0 -29
  106. package/test/node_modules/amqplib/examples/tutorials/callback_api/worker.js +0 -35
  107. package/test/node_modules/amqplib/examples/tutorials/emit_log.js +0 -19
  108. package/test/node_modules/amqplib/examples/tutorials/emit_log_direct.js +0 -20
  109. package/test/node_modules/amqplib/examples/tutorials/emit_log_topic.js +0 -19
  110. package/test/node_modules/amqplib/examples/tutorials/new_task.js +0 -18
  111. package/test/node_modules/amqplib/examples/tutorials/package.json +0 -16
  112. package/test/node_modules/amqplib/examples/tutorials/receive.js +0 -21
  113. package/test/node_modules/amqplib/examples/tutorials/receive_logs.js +0 -28
  114. package/test/node_modules/amqplib/examples/tutorials/receive_logs_direct.js +0 -44
  115. package/test/node_modules/amqplib/examples/tutorials/receive_logs_topic.js +0 -43
  116. package/test/node_modules/amqplib/examples/tutorials/rpc_client.js +0 -52
  117. package/test/node_modules/amqplib/examples/tutorials/rpc_server.js +0 -39
  118. package/test/node_modules/amqplib/examples/tutorials/send.js +0 -23
  119. package/test/node_modules/amqplib/examples/tutorials/worker.js +0 -28
  120. package/test/node_modules/amqplib/examples/waitForConfirms.js +0 -22
  121. package/test/node_modules/amqplib/lib/api_args.js +0 -314
  122. package/test/node_modules/amqplib/lib/bitset.js +0 -130
  123. package/test/node_modules/amqplib/lib/callback_model.js +0 -327
  124. package/test/node_modules/amqplib/lib/channel.js +0 -499
  125. package/test/node_modules/amqplib/lib/channel_model.js +0 -302
  126. package/test/node_modules/amqplib/lib/codec.js +0 -321
  127. package/test/node_modules/amqplib/lib/connect.js +0 -189
  128. package/test/node_modules/amqplib/lib/connection.js +0 -663
  129. package/test/node_modules/amqplib/lib/credentials.js +0 -42
  130. package/test/node_modules/amqplib/lib/defs.js +0 -4966
  131. package/test/node_modules/amqplib/lib/error.js +0 -24
  132. package/test/node_modules/amqplib/lib/format.js +0 -40
  133. package/test/node_modules/amqplib/lib/frame.js +0 -113
  134. package/test/node_modules/amqplib/lib/heartbeat.js +0 -89
  135. package/test/node_modules/amqplib/lib/mux.js +0 -129
  136. package/test/node_modules/amqplib/package.json +0 -37
  137. package/test/node_modules/amqplib/test/bitset.js +0 -69
  138. package/test/node_modules/amqplib/test/callback_api.js +0 -312
  139. package/test/node_modules/amqplib/test/channel.js +0 -621
  140. package/test/node_modules/amqplib/test/channel_api.js +0 -596
  141. package/test/node_modules/amqplib/test/codec.js +0 -237
  142. package/test/node_modules/amqplib/test/connect.js +0 -197
  143. package/test/node_modules/amqplib/test/connection.js +0 -390
  144. package/test/node_modules/amqplib/test/data.js +0 -254
  145. package/test/node_modules/amqplib/test/frame.js +0 -198
  146. package/test/node_modules/amqplib/test/mux.js +0 -204
  147. package/test/node_modules/amqplib/test/util.js +0 -219
  148. package/test/node_modules/buffer-more-ints/.travis.yml +0 -6
  149. package/test/node_modules/buffer-more-ints/LICENSE +0 -19
  150. package/test/node_modules/buffer-more-ints/README.md +0 -69
  151. package/test/node_modules/buffer-more-ints/buffer-more-ints-tests.js +0 -183
  152. package/test/node_modules/buffer-more-ints/buffer-more-ints.js +0 -432
  153. package/test/node_modules/buffer-more-ints/package.json +0 -19
  154. package/test/node_modules/buffer-more-ints/polyfill.js +0 -71
  155. package/test/node_modules/core-util-is/LICENSE +0 -19
  156. package/test/node_modules/core-util-is/README.md +0 -3
  157. package/test/node_modules/core-util-is/lib/util.js +0 -107
  158. package/test/node_modules/core-util-is/package.json +0 -38
  159. package/test/node_modules/debug/LICENSE +0 -20
  160. package/test/node_modules/debug/README.md +0 -481
  161. package/test/node_modules/debug/package.json +0 -59
  162. package/test/node_modules/debug/src/browser.js +0 -269
  163. package/test/node_modules/debug/src/common.js +0 -274
  164. package/test/node_modules/debug/src/index.js +0 -10
  165. package/test/node_modules/debug/src/node.js +0 -263
  166. package/test/node_modules/inherits/LICENSE +0 -16
  167. package/test/node_modules/inherits/README.md +0 -42
  168. package/test/node_modules/inherits/inherits.js +0 -9
  169. package/test/node_modules/inherits/inherits_browser.js +0 -27
  170. package/test/node_modules/inherits/package.json +0 -29
  171. package/test/node_modules/isarray/README.md +0 -54
  172. package/test/node_modules/isarray/build/build.js +0 -209
  173. package/test/node_modules/isarray/component.json +0 -19
  174. package/test/node_modules/isarray/index.js +0 -3
  175. package/test/node_modules/isarray/package.json +0 -25
  176. package/test/node_modules/ms/index.js +0 -162
  177. package/test/node_modules/ms/license.md +0 -21
  178. package/test/node_modules/ms/package.json +0 -37
  179. package/test/node_modules/ms/readme.md +0 -60
  180. package/test/node_modules/querystringify/LICENSE +0 -22
  181. package/test/node_modules/querystringify/README.md +0 -61
  182. package/test/node_modules/querystringify/index.js +0 -118
  183. package/test/node_modules/querystringify/package.json +0 -38
  184. package/test/node_modules/readable-stream/LICENSE +0 -18
  185. package/test/node_modules/readable-stream/README.md +0 -15
  186. package/test/node_modules/readable-stream/duplex.js +0 -1
  187. package/test/node_modules/readable-stream/float.patch +0 -923
  188. package/test/node_modules/readable-stream/lib/_stream_duplex.js +0 -89
  189. package/test/node_modules/readable-stream/lib/_stream_passthrough.js +0 -46
  190. package/test/node_modules/readable-stream/lib/_stream_readable.js +0 -951
  191. package/test/node_modules/readable-stream/lib/_stream_transform.js +0 -209
  192. package/test/node_modules/readable-stream/lib/_stream_writable.js +0 -477
  193. package/test/node_modules/readable-stream/package.json +0 -32
  194. package/test/node_modules/readable-stream/passthrough.js +0 -1
  195. package/test/node_modules/readable-stream/readable.js +0 -10
  196. package/test/node_modules/readable-stream/transform.js +0 -1
  197. package/test/node_modules/readable-stream/writable.js +0 -1
  198. package/test/node_modules/requires-port/.travis.yml +0 -19
  199. package/test/node_modules/requires-port/LICENSE +0 -22
  200. package/test/node_modules/requires-port/README.md +0 -47
  201. package/test/node_modules/requires-port/index.js +0 -38
  202. package/test/node_modules/requires-port/package.json +0 -47
  203. package/test/node_modules/requires-port/test.js +0 -98
  204. package/test/node_modules/safe-buffer/LICENSE +0 -21
  205. package/test/node_modules/safe-buffer/README.md +0 -584
  206. package/test/node_modules/safe-buffer/index.d.ts +0 -187
  207. package/test/node_modules/safe-buffer/index.js +0 -62
  208. package/test/node_modules/safe-buffer/package.json +0 -37
  209. package/test/node_modules/string_decoder/LICENSE +0 -20
  210. package/test/node_modules/string_decoder/README.md +0 -7
  211. package/test/node_modules/string_decoder/index.js +0 -221
  212. package/test/node_modules/string_decoder/package.json +0 -25
  213. package/test/node_modules/url-parse/LICENSE +0 -22
  214. package/test/node_modules/url-parse/README.md +0 -153
  215. package/test/node_modules/url-parse/dist/url-parse.js +0 -755
  216. package/test/node_modules/url-parse/dist/url-parse.min.js +0 -1
  217. package/test/node_modules/url-parse/dist/url-parse.min.js.map +0 -1
  218. package/test/node_modules/url-parse/index.js +0 -589
  219. package/test/node_modules/url-parse/package.json +0 -49
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
4
-
5
- function fib(n) {
6
- var a = 0, b = 1;
7
- for (var i=0; i < n; i++) {
8
- var c = a + b;
9
- a = b; b = c;
10
- }
11
- return a;
12
- }
13
-
14
- function bail(err, conn) {
15
- console.error(err);
16
- if (conn) conn.close(function() { process.exit(1); });
17
- }
18
-
19
- function on_connect(err, conn) {
20
- if (err !== null) return bail(err);
21
-
22
- process.once('SIGINT', function() { conn.close(); });
23
-
24
- var q = 'rpc_queue';
25
-
26
- conn.createChannel(function(err, ch) {
27
- ch.assertQueue(q, {durable: false});
28
- ch.prefetch(1);
29
- ch.consume(q, reply, {noAck:false}, function(err) {
30
- if (err !== null) return bail(err, conn);
31
- console.log(' [x] Awaiting RPC requests');
32
- });
33
-
34
- function reply(msg) {
35
- var n = parseInt(msg.content.toString());
36
- console.log(' [.] fib(%d)', n);
37
- ch.sendToQueue(msg.properties.replyTo,
38
- Buffer.from(fib(n).toString()),
39
- {correlationId: msg.properties.correlationId});
40
- ch.ack(msg);
41
- }
42
- });
43
- }
44
-
45
- amqp.connect(on_connect);
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
4
-
5
- function bail(err, conn) {
6
- console.error(err);
7
- if (conn) conn.close(function() { process.exit(1); });
8
- }
9
-
10
- function on_connect(err, conn) {
11
- if (err !== null) return bail(err);
12
-
13
- var q = 'hello';
14
- var msg = 'Hello World!';
15
-
16
- function on_channel_open(err, ch) {
17
- if (err !== null) return bail(err, conn);
18
- ch.assertQueue(q, {durable: false}, function(err, ok) {
19
- if (err !== null) return bail(err, conn);
20
- ch.sendToQueue(q, Buffer.from(msg));
21
- console.log(" [x] Sent '%s'", msg);
22
- ch.close(function() { conn.close(); });
23
- });
24
- }
25
-
26
- conn.createChannel(on_channel_open);
27
- }
28
-
29
- amqp.connect(on_connect);
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
4
-
5
- function bail(err, conn) {
6
- console.error(err);
7
- if (conn) conn.close(function() { process.exit(1); });
8
- }
9
-
10
- function on_connect(err, conn) {
11
- if (err !== null) return bail(err);
12
- process.once('SIGINT', function() { conn.close(); });
13
-
14
- var q = 'task_queue';
15
-
16
- conn.createChannel(function(err, ch) {
17
- if (err !== null) return bail(err, conn);
18
- ch.assertQueue(q, {durable: true}, function(err, _ok) {
19
- ch.consume(q, doWork, {noAck: false});
20
- console.log(" [*] Waiting for messages. To exit press CTRL+C");
21
- });
22
-
23
- function doWork(msg) {
24
- var body = msg.content.toString();
25
- console.log(" [x] Received '%s'", body);
26
- var secs = body.split('.').length - 1;
27
- setTimeout(function() {
28
- console.log(" [x] Done");
29
- ch.ack(msg);
30
- }, secs * 1000);
31
- }
32
- });
33
- }
34
-
35
- amqp.connect(on_connect);
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
-
5
- amqp.connect('amqp://localhost').then(function(conn) {
6
- return conn.createChannel().then(function(ch) {
7
- var ex = 'logs';
8
- var ok = ch.assertExchange(ex, 'fanout', {durable: false})
9
-
10
- var message = process.argv.slice(2).join(' ') ||
11
- 'info: Hello World!';
12
-
13
- return ok.then(function() {
14
- ch.publish(ex, '', Buffer.from(message));
15
- console.log(" [x] Sent '%s'", message);
16
- return ch.close();
17
- });
18
- }).finally(function() { conn.close(); });
19
- }).catch(console.warn);
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
-
5
- var args = process.argv.slice(2);
6
- var severity = (args.length > 0) ? args[0] : 'info';
7
- var message = args.slice(1).join(' ') || 'Hello World!';
8
-
9
- amqp.connect('amqp://localhost').then(function(conn) {
10
- return conn.createChannel().then(function(ch) {
11
- var ex = 'direct_logs';
12
- var ok = ch.assertExchange(ex, 'direct', {durable: false});
13
-
14
- return ok.then(function() {
15
- ch.publish(ex, severity, Buffer.from(message));
16
- console.log(" [x] Sent %s:'%s'", severity, message);
17
- return ch.close();
18
- });
19
- }).finally(function() { conn.close(); });
20
- }).catch(console.warn);
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
-
5
- var args = process.argv.slice(2);
6
- var key = (args.length > 0) ? args[0] : 'info';
7
- var message = args.slice(1).join(' ') || 'Hello World!';
8
-
9
- amqp.connect('amqp://localhost').then(function(conn) {
10
- return conn.createChannel().then(function(ch) {
11
- var ex = 'topic_logs';
12
- var ok = ch.assertExchange(ex, 'topic', {durable: false});
13
- return ok.then(function() {
14
- ch.publish(ex, key, Buffer.from(message));
15
- console.log(" [x] Sent %s:'%s'", key, message);
16
- return ch.close();
17
- });
18
- }).finally(function() { conn.close(); })
19
- }).catch(console.log);
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
- // Post a new task to the work queue
3
-
4
- var amqp = require('amqplib');
5
-
6
- amqp.connect('amqp://localhost').then(function(conn) {
7
- return conn.createChannel().then(function(ch) {
8
- var q = 'task_queue';
9
- var ok = ch.assertQueue(q, {durable: true});
10
-
11
- return ok.then(function() {
12
- var msg = process.argv.slice(2).join(' ') || "Hello World!";
13
- ch.sendToQueue(q, Buffer.from(msg), {deliveryMode: true});
14
- console.log(" [x] Sent '%s'", msg);
15
- return ch.close();
16
- });
17
- }).finally(function() { conn.close(); });
18
- }).catch(console.warn);
@@ -1,16 +0,0 @@
1
- {
2
- "name": "amqplib-tutorials",
3
- "version": "0.0.1",
4
- "description": "The RabbitMQ tutorials, ported to amqplib",
5
- "main": "send.js",
6
- "dependencies": {
7
- "amqplib": "../..",
8
- "uuid": "*"
9
- },
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1"
12
- },
13
- "repository": "",
14
- "author": "Michael Bridgen <mikeb@squaremobius.net>",
15
- "license": "MPL 2.0"
16
- }
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
-
5
- amqp.connect('amqp://localhost').then(function(conn) {
6
- process.once('SIGINT', function() { conn.close(); });
7
- return conn.createChannel().then(function(ch) {
8
-
9
- var ok = ch.assertQueue('hello', {durable: false});
10
-
11
- ok = ok.then(function(_qok) {
12
- return ch.consume('hello', function(msg) {
13
- console.log(" [x] Received '%s'", msg.content.toString());
14
- }, {noAck: true});
15
- });
16
-
17
- return ok.then(function(_consumeOk) {
18
- console.log(' [*] Waiting for messages. To exit press CTRL+C');
19
- });
20
- });
21
- }).catch(console.warn);
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
-
5
- amqp.connect('amqp://localhost').then(function(conn) {
6
- process.once('SIGINT', function() { conn.close(); });
7
- return conn.createChannel().then(function(ch) {
8
- var ok = ch.assertExchange('logs', 'fanout', {durable: false});
9
- ok = ok.then(function() {
10
- return ch.assertQueue('', {exclusive: true});
11
- });
12
- ok = ok.then(function(qok) {
13
- return ch.bindQueue(qok.queue, 'logs', '').then(function() {
14
- return qok.queue;
15
- });
16
- });
17
- ok = ok.then(function(queue) {
18
- return ch.consume(queue, logMessage, {noAck: true});
19
- });
20
- return ok.then(function() {
21
- console.log(' [*] Waiting for logs. To exit press CTRL+C');
22
- });
23
-
24
- function logMessage(msg) {
25
- console.log(" [x] '%s'", msg.content.toString());
26
- }
27
- });
28
- }).catch(console.warn);
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
- var basename = require('path').basename;
5
-
6
- var severities = process.argv.slice(2);
7
- if (severities.length < 1) {
8
- console.warn('Usage: %s [info] [warning] [error]',
9
- basename(process.argv[1]));
10
- process.exit(1);
11
- }
12
-
13
- amqp.connect('amqp://localhost').then(function(conn) {
14
- process.once('SIGINT', function() { conn.close(); });
15
- return conn.createChannel().then(function(ch) {
16
- var ex = 'direct_logs';
17
-
18
- var ok = ch.assertExchange(ex, 'direct', {durable: false});
19
-
20
- ok = ok.then(function() {
21
- return ch.assertQueue('', {exclusive: true});
22
- });
23
-
24
- ok = ok.then(function(qok) {
25
- var queue = qok.queue;
26
- return Promise.all(severities.map(function(sev) {
27
- ch.bindQueue(queue, ex, sev);
28
- })).then(function() { return queue; });
29
- });
30
-
31
- ok = ok.then(function(queue) {
32
- return ch.consume(queue, logMessage, {noAck: true});
33
- });
34
- return ok.then(function() {
35
- console.log(' [*] Waiting for logs. To exit press CTRL+C.');
36
- });
37
-
38
- function logMessage(msg) {
39
- console.log(" [x] %s:'%s'",
40
- msg.fields.routingKey,
41
- msg.content.toString());
42
- }
43
- });
44
- }).catch(console.warn);
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
- var basename = require('path').basename;
5
-
6
- var keys = process.argv.slice(2);
7
- if (keys.length < 1) {
8
- console.log('Usage: %s pattern [pattern...]',
9
- basename(process.argv[1]));
10
- process.exit(1);
11
- }
12
-
13
- amqp.connect('amqp://localhost').then(function(conn) {
14
- process.once('SIGINT', function() { conn.close(); });
15
- return conn.createChannel().then(function(ch) {
16
- var ex = 'topic_logs';
17
- var ok = ch.assertExchange(ex, 'topic', {durable: false});
18
-
19
- ok = ok.then(function() {
20
- return ch.assertQueue('', {exclusive: true});
21
- });
22
-
23
- ok = ok.then(function(qok) {
24
- var queue = qok.queue;
25
- return Promise.all(keys.map(function(rk) {
26
- ch.bindQueue(queue, ex, rk);
27
- })).then(function() { return queue; });
28
- });
29
-
30
- ok = ok.then(function(queue) {
31
- return ch.consume(queue, logMessage, {noAck: true});
32
- });
33
- return ok.then(function() {
34
- console.log(' [*] Waiting for logs. To exit press CTRL+C.');
35
- });
36
-
37
- function logMessage(msg) {
38
- console.log(" [x] %s:'%s'",
39
- msg.fields.routingKey,
40
- msg.content.toString());
41
- }
42
- });
43
- }).catch(console.warn);
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
- var basename = require('path').basename;
5
- var uuid = require('node-uuid');
6
-
7
- // I've departed from the form of the original RPC tutorial, which
8
- // needlessly introduces a class definition, and doesn't even
9
- // parameterise the request.
10
-
11
- var n;
12
- try {
13
- if (process.argv.length < 3) throw Error('Too few args');
14
- n = parseInt(process.argv[2]);
15
- }
16
- catch (e) {
17
- console.error(e);
18
- console.warn('Usage: %s number', basename(process.argv[1]));
19
- process.exit(1);
20
- }
21
-
22
- amqp.connect('amqp://localhost').then(function(conn) {
23
- return conn.createChannel().then(function(ch) {
24
- return new Promise(function(resolve) {
25
- var corrId = uuid();
26
- function maybeAnswer(msg) {
27
- if (msg.properties.correlationId === corrId) {
28
- resolve(msg.content.toString());
29
- }
30
- }
31
-
32
- var ok = ch.assertQueue('', {exclusive: true})
33
- .then(function(qok) { return qok.queue; });
34
-
35
- ok = ok.then(function(queue) {
36
- return ch.consume(queue, maybeAnswer, {noAck: true})
37
- .then(function() { return queue; });
38
- });
39
-
40
- ok = ok.then(function(queue) {
41
- console.log(' [x] Requesting fib(%d)', n);
42
- ch.sendToQueue('rpc_queue', Buffer.from(n.toString()), {
43
- correlationId: corrId, replyTo: queue
44
- });
45
- });
46
- });
47
- })
48
- .then(function(fibN) {
49
- console.log(' [.] Got %d', fibN);
50
- })
51
- .finally(function() { conn.close(); });
52
- }).catch(console.warn);
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
-
5
- function fib(n) {
6
- // Do it the ridiculous, but not most ridiculous, way. For better,
7
- // see http://nayuki.eigenstate.org/page/fast-fibonacci-algorithms
8
- var a = 0, b = 1;
9
- for (var i=0; i < n; i++) {
10
- var c = a + b;
11
- a = b; b = c;
12
- }
13
- return a;
14
- }
15
-
16
- amqp.connect('amqp://localhost').then(function(conn) {
17
- process.once('SIGINT', function() { conn.close(); });
18
- return conn.createChannel().then(function(ch) {
19
- var q = 'rpc_queue';
20
- var ok = ch.assertQueue(q, {durable: false});
21
- var ok = ok.then(function() {
22
- ch.prefetch(1);
23
- return ch.consume(q, reply);
24
- });
25
- return ok.then(function() {
26
- console.log(' [x] Awaiting RPC requests');
27
- });
28
-
29
- function reply(msg) {
30
- var n = parseInt(msg.content.toString());
31
- console.log(' [.] fib(%d)', n);
32
- var response = fib(n);
33
- ch.sendToQueue(msg.properties.replyTo,
34
- Buffer.from(response.toString()),
35
- {correlationId: msg.properties.correlationId});
36
- ch.ack(msg);
37
- }
38
- });
39
- }).catch(console.warn);
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib');
4
-
5
- amqp.connect('amqp://localhost').then(function(conn) {
6
- return conn.createChannel().then(function(ch) {
7
- var q = 'hello';
8
- var msg = 'Hello World!';
9
-
10
- var ok = ch.assertQueue(q, {durable: false});
11
-
12
- return ok.then(function(_qok) {
13
- // NB: `sentToQueue` and `publish` both return a boolean
14
- // indicating whether it's OK to send again straight away, or
15
- // (when `false`) that you should wait for the event `'drain'`
16
- // to fire before writing again. We're just doing the one write,
17
- // so we'll ignore it.
18
- ch.sendToQueue(q, Buffer.from(msg));
19
- console.log(" [x] Sent '%s'", msg);
20
- return ch.close();
21
- });
22
- }).finally(function() { conn.close(); });
23
- }).catch(console.warn);
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env node
2
- // Process tasks from the work queue
3
-
4
- var amqp = require('amqplib');
5
-
6
- amqp.connect('amqp://localhost').then(function(conn) {
7
- process.once('SIGINT', function() { conn.close(); });
8
- return conn.createChannel().then(function(ch) {
9
- var ok = ch.assertQueue('task_queue', {durable: true});
10
- ok = ok.then(function() { ch.prefetch(1); });
11
- ok = ok.then(function() {
12
- ch.consume('task_queue', doWork, {noAck: false});
13
- console.log(" [*] Waiting for messages. To exit press CTRL+C");
14
- });
15
- return ok;
16
-
17
- function doWork(msg) {
18
- var body = msg.content.toString();
19
- console.log(" [x] Received '%s'", body);
20
- var secs = body.split('.').length - 1;
21
- //console.log(" [x] Task takes %d seconds", secs);
22
- setTimeout(function() {
23
- console.log(" [x] Done");
24
- ch.ack(msg);
25
- }, secs * 1000);
26
- }
27
- });
28
- }).catch(console.warn);
@@ -1,22 +0,0 @@
1
- var amqp = require('../');
2
-
3
- var NUM_MSGS = 20;
4
-
5
- function mkCallback(i) {
6
- return (i % 2) === 0 ? function(err) {
7
- if (err !== null) { console.error('Message %d failed!', i); }
8
- else { console.log('Message %d confirmed', i); }
9
- } : null;
10
- }
11
-
12
- amqp.connect().then(function(c) {
13
- c.createConfirmChannel().then(function(ch) {
14
- for (var i=0; i < NUM_MSGS; i++) {
15
- ch.publish('amq.topic', 'whatever', Buffer.from('blah'), {}, mkCallback(i));
16
- }
17
- ch.waitForConfirms().then(function() {
18
- console.log('All messages done');
19
- c.close();
20
- }).catch(console.error);
21
- });
22
- });