Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

js_examples: Migrate and test register_queue example.

Kartik Srivastava5a4d31825cdf
diff --git a/templates/zerver/api/register-queue.md b/templates/zerver/api/register-queue.md
index 25b64148f1a..8912885a304 100644
--- a/templates/zerver/api/register-queue.md
+++ b/templates/zerver/api/register-queue.md
@@ -55,23 +55,8 @@ potentially messy races, etc.
{tab|js}
More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
-```js
-const zulip = require('zulip-js');
-
-// Pass the path to your zuliprc file here.
-const config = {
- zuliprc: 'zuliprc',
-};
-
-zulip(config).then((client) => {
- // Register a queue
- const params = {
- event_types: ['message']
- };
- client.queues.register(params).then(console.log);
-});
-
-```
+
+{generate_code_example(javascript)|/register:post|example}
{tab|curl}
diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js
index 469185370fe..292f7db262c 100644
--- a/zerver/openapi/javascript_examples.js
+++ b/zerver/openapi/javascript_examples.js
@@ -45,6 +45,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.get_stream_topics);
await generate_validation_data(client, examples.get_subscriptions);
await generate_validation_data(client, examples.get_users);
+ await generate_validation_data(client, examples.register_queue);
console.log(JSON.stringify(response_data));
return;
@@ -188,4 +189,15 @@ add_example('get_users', '/users:get', 200, async (client) => {
return [result_1, result_2];
});
+add_example('register_queue', '/register:post', 200, async (client) => {
+ // {code_example|start}
+ // Register a queue
+ const params = {
+ event_types: ['message'],
+ };
+
+ return await client.queues.register(params);
+ // {code_example|end}
+});
+
main();