typespeed 2.0.21 → 2.0.22

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 +25 -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 +25 -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,22 +0,0 @@
1
- var raw_connect = require('./lib/connect').connect;
2
- var CallbackModel = require('./lib/callback_model').CallbackModel;
3
-
4
- // Supports three shapes:
5
- // connect(url, options, callback)
6
- // connect(url, callback)
7
- // connect(callback)
8
- function connect(url, options, cb) {
9
- if (typeof url === 'function')
10
- cb = url, url = false, options = false;
11
- else if (typeof options === 'function')
12
- cb = options, options = false;
13
-
14
- raw_connect(url, options, function(err, c) {
15
- if (err === null) cb(null, new CallbackModel(c));
16
- else cb(err);
17
- });
18
- };
19
-
20
- module.exports.connect = connect;
21
- module.exports.credentials = require('./lib/credentials');
22
- module.exports.IllegalOperationError = require('./lib/error').IllegalOperationError;
@@ -1,16 +0,0 @@
1
- var raw_connect = require('./lib/connect').connect;
2
- var ChannelModel = require('./lib/channel_model').ChannelModel;
3
- var promisify = require('util').promisify;
4
-
5
- function connect(url, connOptions) {
6
- return promisify(function(cb) {
7
- return raw_connect(url, connOptions, cb);
8
- })()
9
- .then(function(conn) {
10
- return new ChannelModel(conn);
11
- });
12
- };
13
-
14
- module.exports.connect = connect;
15
- module.exports.credentials = require('./lib/credentials');
16
- module.exports.IllegalOperationError = require('./lib/error').IllegalOperationError;
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Example of using a headers exchange
4
-
5
- var amqp = require('../')
6
-
7
- amqp.connect().then(function(conn) {
8
- return conn.createChannel().then(withChannel);
9
- }, console.error);
10
-
11
- function withChannel(ch) {
12
- // NB the type of the exchange is 'headers'
13
- ch.assertExchange('matching exchange', 'headers').then(function(ex) {
14
- ch.assertQueue().then(function(q) {
15
- bindAndConsume(ch, ex, q).then(function() {
16
- send(ch, ex);
17
- });
18
- });
19
- });
20
- }
21
-
22
- function bindAndConsume(ch, ex, q) {
23
- // When using a headers exchange, the headers to be matched go in
24
- // the binding arguments. The routing key is ignore, so best left
25
- // empty.
26
-
27
- // 'x-match' is 'all' or 'any', meaning "all fields must match" or
28
- // "at least one field must match", respectively. The values to be
29
- // matched go in subsequent fields.
30
- ch.bindQueue(q.queue, ex.exchange, '', {'x-match': 'any',
31
- 'foo': 'bar',
32
- 'baz': 'boo'});
33
- return ch.consume(q.queue, function(msg) {
34
- console.log(msg.content.toString());
35
- }, {noAck: true});
36
- }
37
-
38
- function send(ch, ex) {
39
- // The headers for a message are given as an option to `publish`:
40
- ch.publish(ex.exchange, '', Buffer.from('hello'), {headers: {baz: 'boo'}});
41
- ch.publish(ex.exchange, '', Buffer.from('world'), {headers: {foo: 'bar'}});
42
- }
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
- const co = require('co');
5
- const amqp = require('amqplib');
6
- const readline = require('readline');
7
-
8
- co(function* () {
9
- const myConsumer = (msg) => {
10
- if (msg !== null) {
11
- console.log('consuming message %s in generator', JSON.stringify(msg.content.toString()));
12
- }
13
- };
14
- const conn = yield amqp.connect('amqp://localhost');
15
- try {
16
- // create a message to consume
17
- const q = 'hello';
18
- const msg = 'Hello World!';
19
- const channel = yield conn.createChannel();
20
- yield channel.assertQueue(q);
21
- channel.sendToQueue(q, Buffer.from(msg));
22
- console.log(" [x] Sent '%s'", msg);
23
- // consume the message
24
- yield channel.consume(q, myConsumer, { noAck: true });
25
- }
26
- catch (e) {
27
- throw e;
28
- }
29
- }).catch(err => {
30
- console.warn('Error:', err);
31
- });
32
-
33
- const rl = readline.createInterface({
34
- input: process.stdin,
35
- output: process.stdout
36
- });
37
-
38
- // pend until message is consumed
39
- rl.question('newline to exit', () => process.exit());
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
-
5
- // NB this requires the module 'co':
6
- // npm install co
7
- const co = require('co');
8
- const amqp = require('amqplib');
9
-
10
- co(function* () {
11
- // connection errors are handled in the co .catch handler
12
- const conn = yield amqp.connect('amqp://localhost');
13
-
14
- // try catch will throw any errors from the yielding the following promises to the co .catch handler
15
- try {
16
- const q = 'hello';
17
- const msg = 'Hello World!';
18
-
19
- // use a confirm channel so we can check the message is sent OK.
20
- const channel = yield conn.createConfirmChannel();
21
-
22
- yield channel.assertQueue(q);
23
-
24
- channel.sendToQueue(q, Buffer.from(msg));
25
-
26
- // if message has been nacked, this will result in an error (rejected promise);
27
- yield channel.waitForConfirms();
28
-
29
- console.log(" [x] Sent '%s'", msg);
30
-
31
- channel.close();
32
- }
33
- catch (e) {
34
- throw e;
35
- }
36
- finally {
37
- conn.close();
38
- }
39
-
40
- }).catch(err => {
41
- console.warn('Error:', err);
42
- });
@@ -1,64 +0,0 @@
1
- // Example of using a TLS/SSL connection. Note that the server must be
2
- // configured to accept SSL connections; see, for example,
3
- // http://www.rabbitmq.com/ssl.html.
4
- //
5
- // When trying this out, I followed the RabbitMQ SSL guide above,
6
- // almost verbatim. I set the CN of the server certificate to
7
- // 'localhost' rather than $(hostname) (since on my MBP hostname ends
8
- // up being "<blah>.local", which is just weird). My client
9
- // certificates etc., are in `../etc/client/`. My testca certificate
10
- // is in `../etc/testca` and server certs etc., in `../etc/server`,
11
- // and I've made a `rabbitmq.config` file, with which I start
12
- // RabbitMQ:
13
- //
14
- // RABBITMQ_CONFIG_FILE=`pwd`/../etc/server/rabbitmq \
15
- // /usr/local/sbin/rabbitmq-server &
16
- //
17
- // A way to check RabbitMQ's running with SSL OK is to use
18
- //
19
- // openssl s_client -connect localhost:5671
20
-
21
- var amqp = require('../');
22
- var fs = require('fs');
23
-
24
- // Assemble the SSL options; for verification we need at least
25
- // * a certificate to present to the server ('cert', in PEM format)
26
- // * the private key for the certificate ('key', in PEM format)
27
- // * (possibly) a passphrase for the private key
28
- //
29
- // The first two may be replaced with a PKCS12 file ('pfx', in pkcs12
30
- // format)
31
-
32
- // We will also want to list the CA certificates that we will trust,
33
- // since we're using a self-signed certificate. It is NOT recommended
34
- // to use `rejectUnauthorized: false`.
35
-
36
- // Options for full client and server verification:
37
- var opts = {
38
- cert: fs.readFileSync('../etc/client/cert.pem'),
39
- key: fs.readFileSync('../etc/client/key.pem'),
40
- // cert and key or
41
- // pfx: fs.readFileSync('../etc/client/keycert.p12'),
42
- passphrase: 'MySecretPassword',
43
- ca: [fs.readFileSync('../etc/testca/cacert.pem')]
44
- };
45
-
46
- // Options for just confidentiality. This requires RabbitMQ's SSL
47
- // configuration to include the items
48
- //
49
- // {verify, verify_none},
50
- // {fail_if_no_peer_cert,false}
51
- //
52
- // var opts = { ca: [fs.readFileSync('../etc/testca/cacert.pem')] };
53
-
54
- // Option to use the SSL client certificate for authentication
55
- // opts.credentials = amqp.credentials.external();
56
-
57
- var open = amqp.connect('amqps://localhost', opts);
58
-
59
- open.then(function(conn) {
60
- process.on('SIGINT', conn.close.bind(conn));
61
- return conn.createChannel().then(function(ch) {
62
- ch.sendToQueue('foo', Buffer.from('Hello World!'));
63
- });
64
- }).then(null, console.warn);
@@ -1,93 +0,0 @@
1
- # RabbitMQ tutorials
2
-
3
- This directory contains the [RabbitMQ tutorials][rabbitmq-tutes],
4
- ported to amqplib. The sub-directory `callback_api` has translations
5
- of the tutorial programs to the callback-oriented API.
6
-
7
- ## Preparation
8
-
9
- To run the tutorial code, you need amqplib installed. Assuming you are
10
- in a clone of the amqplib repository, from the tutorials directory:
11
-
12
- npm install
13
-
14
- or to use the latest released version,
15
-
16
- npm install amqplib
17
-
18
- Then just run each file as a script, e.g., in bash
19
-
20
- ./send.js
21
-
22
- or
23
-
24
- node send.js
25
-
26
- or
27
-
28
- nave use 0.8 node send.js
29
-
30
- ## [Tutorial one: Hello World!][tute-one]
31
-
32
- A "Hello World" example, with one script sending a message to a queue,
33
- and another receiving messages from the same queue.
34
-
35
- * [send.js](send.js)
36
- * [receive.js](receive.js)
37
-
38
- ## [Tutorial two: Work queues][tute-two]
39
-
40
- Using RabbitMQ as a work queue; `new_task` creates a task, and
41
- `worker` processes tasks. Multiple `worker` process will share the
42
- tasks among them. Long-running tasks are simulated by supplying a
43
- string with dots, e.g., '...' to `new_task`. Each dot makes the worker
44
- "work" for a second.
45
-
46
- * [new_task.js](new_task.js)
47
- * [worker.js](worker.js)
48
-
49
- ## [Tutorial three: Publish/Subscribe][tute-three]
50
-
51
- Using RabbitMQ as a broadcast mechanism. `emit_log` sends a "log"
52
- message to a fanout exchange, and all `receive_logs` processes receive
53
- log messages.
54
-
55
- * [emit_log.js](emit_log.js)
56
- * [receive_logs.js](receive_logs.js)
57
-
58
- ## [Tutorial four: Routing][tute-four]
59
-
60
- Using RabbitMQ as a routing ('somecast') mechanism. `emit_log_direct`
61
- sends a log message with a severity, and all `receive_logs_direct`
62
- processes receive log messages for the severities on which they are
63
- listening.
64
-
65
- * [emit_log_direct.js](emit_log_direct.js)
66
- * [receive_logs_direct.js](receive_logs_direct.js)
67
-
68
- ## [Tutorial five: Topics][tute-five]
69
-
70
- Extends the previous tutorial to routing with wildcarded patterns.
71
-
72
- * [emit_log_topic.js](emit_log_topic.js)
73
- * [receive_logs_topic.js](receive_logs_topic.js)
74
-
75
- ## [Tutorial six: RPC][tute-six]
76
-
77
- Using RabbitMQ as an RPC intermediary, queueing requests for servers
78
- and routing replies back to clients.
79
-
80
- * [rpc_server.js](rpc_server.js)
81
- * [rpc_client.js](rpc_client.js)
82
-
83
- I depart slightly from the original tutorial code, which I think has
84
- some needless object-orientation (in the Python code; you don't get a
85
- choice about needless object-orientation in Java).
86
-
87
- [rabbitmq-tutes]: http://github.com/rabbitmq/rabbitmq-tutorials
88
- [tute-one]: http://www.rabbitmq.com/tutorials/tutorial-one-javascript.html
89
- [tute-two]: http://www.rabbitmq.com/tutorials/tutorial-two-javascript.html
90
- [tute-three]: http://www.rabbitmq.com/tutorials/tutorial-three-javascript.html
91
- [tute-four]: http://www.rabbitmq.com/tutorials/tutorial-four-javascript.html
92
- [tute-five]: http://www.rabbitmq.com/tutorials/tutorial-five-javascript.html
93
- [tute-six]: http://www.rabbitmq.com/tutorials/tutorial-six-javascript.html
@@ -1,28 +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 ex = 'logs';
14
-
15
- function on_channel_open(err, ch) {
16
- if (err !== null) return bail(err, conn);
17
- ch.assertExchange(ex, 'fanout', {durable: false});
18
- var msg = process.argv.slice(2).join(' ') ||
19
- 'info: Hello World!';
20
- ch.publish(ex, '', Buffer.from(msg));
21
- console.log(" [x] Sent '%s'", msg);
22
- ch.close(function() { conn.close(); });
23
- }
24
-
25
- conn.createChannel(on_channel_open);
26
- }
27
-
28
- amqp.connect(on_connect);
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
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
- function bail(err, conn) {
10
- console.error(err);
11
- if (conn) conn.close(function() { process.exit(1); });
12
- }
13
-
14
- function on_connect(err, conn) {
15
- if (err !== null) return bail(err);
16
-
17
- var ex = 'direct_logs';
18
- var exopts = {durable: false};
19
-
20
- function on_channel_open(err, ch) {
21
- if (err !== null) return bail(err, conn);
22
- ch.assertExchange(ex, 'direct', exopts, function(err, ok) {
23
- ch.publish(ex, severity, Buffer.from(message));
24
- ch.close(function() { conn.close(); });
25
- });
26
- }
27
- conn.createChannel(on_channel_open);
28
- }
29
-
30
- amqp.connect(on_connect);
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
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
- function bail(err, conn) {
10
- console.error(err);
11
- if (conn) conn.close(function() { process.exit(1); });
12
- }
13
-
14
- function on_connect(err, conn) {
15
- if (err !== null) return bail(err);
16
- var ex = 'topic_logs', exopts = {durable: false};
17
- conn.createChannel(function(err, ch) {
18
- ch.assertExchange(ex, 'topic', exopts, function(err, ok) {
19
- if (err !== null) return bail(err, conn);
20
- ch.publish(ex, key, Buffer.from(message));
21
- console.log(" [x] Sent %s:'%s'", key, message);
22
- ch.close(function() { conn.close(); });
23
- });
24
- });
25
- }
26
-
27
- amqp.connect(on_connect);
@@ -1,27 +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 = 'task_queue';
14
-
15
- conn.createChannel(function(err, ch) {
16
- if (err !== null) return bail(err, conn);
17
- ch.assertQueue(q, {durable: true}, function(err, _ok) {
18
- if (err !== null) return bail(err, conn);
19
- var msg = process.argv.slice(2).join(' ') || "Hello World!";
20
- ch.sendToQueue(q, Buffer.from(msg), {persistent: true});
21
- console.log(" [x] Sent '%s'", msg);
22
- ch.close(function() { conn.close(); });
23
- });
24
- });
25
- }
26
-
27
- amqp.connect(on_connect);
@@ -1,30 +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 = 'hello';
15
-
16
- function on_channel_open(err, ch) {
17
- ch.assertQueue(q, {durable: false}, function(err, ok) {
18
- if (err !== null) return bail(err, conn);
19
- ch.consume(q, function(msg) { // message callback
20
- console.log(" [x] Received '%s'", msg.content.toString());
21
- }, {noAck: true}, function(_consumeOk) { // consume callback
22
- console.log(' [*] Waiting for messages. To exit press CTRL+C');
23
- });
24
- });
25
- }
26
-
27
- conn.createChannel(on_channel_open);
28
- }
29
-
30
- amqp.connect(on_connect);
@@ -1,36 +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 ex = 'logs';
15
-
16
- function on_channel_open(err, ch) {
17
- if (err !== null) return bail(err, conn);
18
- ch.assertQueue('', {exclusive: true}, function(err, ok) {
19
- var q = ok.queue;
20
- ch.bindQueue(q, ex, '');
21
- ch.consume(q, logMessage, {noAck: true}, function(err, ok) {
22
- if (err !== null) return bail(err, conn);
23
- console.log(" [*] Waiting for logs. To exit press CTRL+C.");
24
- });
25
- });
26
- }
27
-
28
- function logMessage(msg) {
29
- if (msg)
30
- console.log(" [x] '%s'", msg.content.toString());
31
- }
32
-
33
- conn.createChannel(on_channel_open);
34
- }
35
-
36
- amqp.connect(on_connect);
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
4
-
5
- var basename = require('path').basename;
6
-
7
- var severities = process.argv.slice(2);
8
- if (severities.length < 1) {
9
- console.log('Usage %s [info] [warning] [error]',
10
- basename(process.argv[1]));
11
- process.exit(1);
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
- process.once('SIGINT', function() { conn.close(); });
22
-
23
- conn.createChannel(function(err, ch) {
24
- if (err !== null) return bail(err, conn);
25
- var ex = 'direct_logs', exopts = {durable: false};
26
-
27
- ch.assertExchange(ex, 'direct', exopts);
28
- ch.assertQueue('', {exclusive: true}, function(err, ok) {
29
- if (err !== null) return bail(err, conn);
30
-
31
- var queue = ok.queue, i = 0;
32
-
33
- function sub(err) {
34
- if (err !== null) return bail(err, conn);
35
- else if (i < severities.length) {
36
- ch.bindQueue(queue, ex, severities[i], {}, sub);
37
- i++;
38
- }
39
- }
40
-
41
- ch.consume(queue, logMessage, {noAck: true}, function(err) {
42
- if (err !== null) return bail(err, conn);
43
- console.log(' [*] Waiting for logs. To exit press CTRL+C.');
44
- sub(null);
45
- });
46
- });
47
- });
48
- }
49
-
50
- function logMessage(msg) {
51
- console.log(" [x] %s:'%s'",
52
- msg.fields.routingKey,
53
- msg.content.toString());
54
- }
55
-
56
- amqp.connect(on_connect);
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
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
- function bail(err, conn) {
14
- console.error(err);
15
- if (conn) conn.close(function() { process.exit(1); });
16
- }
17
-
18
- function on_connect(err, conn) {
19
- if (err !== null) return bail(err);
20
- process.once('SIGINT', function() { conn.close(); });
21
-
22
- conn.createChannel(function(err, ch) {
23
- if (err !== null) return bail(err, conn);
24
- var ex = 'topic_logs', exopts = {durable: false};
25
-
26
- ch.assertExchange(ex, 'topic', exopts);
27
- ch.assertQueue('', {exclusive: true}, function(err, ok) {
28
- if (err !== null) return bail(err, conn);
29
-
30
- var queue = ok.queue, i = 0;
31
-
32
- function sub(err) {
33
- if (err !== null) return bail(err, conn);
34
- else if (i < keys.length) {
35
- ch.bindQueue(queue, ex, keys[i], {}, sub);
36
- i++;
37
- }
38
- }
39
-
40
- ch.consume(queue, logMessage, {noAck: true}, function(err) {
41
- if (err !== null) return bail(err, conn);
42
- console.log(' [*] Waiting for logs. To exit press CTRL+C.');
43
- sub(null);
44
- });
45
- });
46
- });
47
- }
48
-
49
- function logMessage(msg) {
50
- console.log(" [x] %s:'%s'",
51
- msg.fields.routingKey,
52
- msg.content.toString());
53
- }
54
-
55
- amqp.connect(on_connect);
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var amqp = require('amqplib/callback_api');
4
- var basename = require('path').basename;
5
- var uuid = require('node-uuid');
6
-
7
- var n;
8
- try {
9
- if (process.argv.length < 3) throw Error('Too few args');
10
- n = parseInt(process.argv[2]);
11
- }
12
- catch (e) {
13
- console.error(e);
14
- console.warn('Usage: %s number', basename(process.argv[1]));
15
- process.exit(1);
16
- }
17
-
18
- function bail(err, conn) {
19
- console.error(err);
20
- if (conn) conn.close(function() { process.exit(1); });
21
- }
22
-
23
- function on_connect(err, conn) {
24
- if (err !== null) return bail(err);
25
- conn.createChannel(function(err, ch) {
26
- if (err !== null) return bail(err, conn);
27
-
28
- var correlationId = uuid();
29
- function maybeAnswer(msg) {
30
- if (msg.properties.correlationId === correlationId) {
31
- console.log(' [.] Got %d', msg.content.toString());
32
- }
33
- else return bail(new Error('Unexpected message'), conn);
34
- ch.close(function() { conn.close(); });
35
- }
36
-
37
- ch.assertQueue('', {exclusive: true}, function(err, ok) {
38
- if (err !== null) return bail(err, conn);
39
- var queue = ok.queue;
40
- ch.consume(queue, maybeAnswer, {noAck:true});
41
- console.log(' [x] Requesting fib(%d)', n);
42
- ch.sendToQueue('rpc_queue', Buffer.from(n.toString()), {
43
- replyTo: queue, correlationId: correlationId
44
- });
45
- });
46
- });
47
- }
48
-
49
- amqp.connect(on_connect);