How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • amqp.assertQueue = async function (queue, exchange, key) {
      const connection = await amqp.connect('amqp://localhost');
      channel = await connection.createChannel();
    
      await channel.assertExchange(exchange, 'topic');
      await channel.assertQueue(queue);
      await channel.bindQueue(queue, exchange, key);
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">import</span> amqp</code></pre>
    /kozzztya/feathers-amqp-events mit
    0
  • async function connectToBroker() {
      connection = await amqp.connect(`amqp://localhost:${AMQP_PORT}`);
      channel = await connection.createChannel();
      channel.assertExchange(exchangeName, 'fanout', { durable: false });
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">connectToBroker</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Promise</span><span class="token operator">&lt;</span><span class="token keyword">void</span><span class="token operator">></span></code></pre>
    /civicteam/feathers-amqp-client mit
    0
  • async connect() {
    
            let connection = await amqp.connect(this.amqpUrl);
            let channel = await connection.createChannel();
    
            await this.senders.forEach((sender) => sender.init(channel));
    
            return connection;
        }
    
        
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>method<span class="token punctuation">)</span> AmqpListener<span class="token punctuation">.</span><span class="token function">connect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Promise</span><span class="token operator">&lt;</span><span class="token builtin">any</span><span class="token operator">></span></code><div class="typing-tooltip-markup"><em>@returns</em></div></pre>
    /IBA-Group-IT/IoT-data-simulator apache-2.0
    0
  • var open = require('amqplib').connect();
    open.then(function(c) {
      c.createConfirmChannel().then(function(ch) {
        ch.sendToQueue('foo', new Buffer('foobar'), {},
          function(err, ok) {
            if (err !== null)
              console.warn('Message nacked!');
            else
              console.log('Message acked');
        });
      });
    });
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">var</span> open<span class="token operator">:</span> Bluebird<span class="token operator">&lt;</span>ChannelModel<span class="token operator">></span></code></pre>
    Docs
    0
  • async function run() {
        let client = await amqp.connect(url);
        let channel = await client.createChannel();
        await channel.assertQueue(q);
        await channel.sendToQueue(q, Buffer.from('something to do'));
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">run</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Promise</span><span class="token operator">&lt;</span><span class="token keyword">void</span><span class="token operator">></span></code></pre>
    /solzimer/nsyslog MIT
    0
  • Client.prototype.connect = async function () {
      if (!this._channel) {
        
        //...
    conn.on('error', e => {
          this._channel = null;
          console.error('amqplib-rpc-client: ' + e);
        });
        const channel = await conn.createChannel();
    
        const q = await channel.assertQueue('', { exclusive: true, autoDelete: true });
        
        //...
    }
      
      //...
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">class</span> <span class="token class-name">Client</span> <span class="token keyword">function</span> <span class="token function">Client</span><span class="token punctuation">(</span><span class="token parameter">options<span class="token operator">:</span> any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token keyword">void</span></code></pre>
    /wbenxin/amqplib-rpc mit
    0
  • async function producer() {
      const connectOptions = {
        protocol: 'amqps',
        hostname: process.env.RABBITMQ_HOST,
        port: 5671,
        username: process.env.RABBITMQ_USERNAME,
        password: process.env.RABBITMQ_PASSWORD,
      };
    
      const connection = await amqp.connect(connectOptions);
      const channel = await connection.createChannel();
      const queueName = process.env.QUEUE_NAME;
      await channel.assertQueue(queueName);
      
      //...
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">producer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Promise</span><span class="token operator">&lt;</span><span class="token punctuation">{</span> statusCode<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token operator">></span></code></pre>
    /serverless/serverless mit
    0
  • connect().use(serveStatic(__dirname)).listen(9090, () => {
        process.stdout.write('Server running on 9090...\n');
    });
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token function">connect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> connect<span class="token punctuation">.</span>Server <span class="token keyword">import</span> connect</code><div class="typing-tooltip-markup">Create a new connect server.</div></pre>
    /DevExpress/testcafe MIT
    0
  • // require module
    // require module
    var connect = require('connect')
     
    // create app
    // create app
    var app = connect()
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">function</span> <span class="token function">connect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> createServer<span class="token punctuation">.</span><span class="token function">Server</span> <span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">namespace</span> connect <span class="token keyword">import</span> connect</code><div class="typing-tooltip-markup">Create a new connect server.</div></pre>
    Docs
    0
  • connect().use(serveStatic(__dirname)).listen(8181, function(){
        console.log('Server running on 8181...');
    });
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token function">connect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> connect<span class="token punctuation">.</span>Server <span class="token keyword">import</span> connect</code><div class="typing-tooltip-markup">Create a new connect server.</div></pre>
    /fuhrmanator/GIFT-grammar-PEG.js mit
    0
  • module.exports = function(spec) {
      spec = _.assign({ fallthrough: false }, spec);
    
      const app = connect();
      const listen = app.listen.bind(app);
    
      // Override method because port and host are given
      // in the spec object
      
      //...
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">module</span> <span class="token keyword">export</span><span class="token operator">=</span> <span class="token punctuation">(</span>property<span class="token punctuation">)</span> <span class="token keyword">export</span><span class="token operator">=</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">spec<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token builtin">any</span></code></pre>
    /firebase/superstatic mit
    0
  • var app = connect();
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">var</span> app<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • const rootReducer = combineReducers({
        language: languageProviderReducer,
        router: connectRouter(history),
        ...injectedReducers,
      });
    
      
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> rootReducer<span class="token operator">:</span> Reducer<span class="token operator">&lt;</span><span class="token punctuation">{</span> language<span class="token operator">:</span> <span class="token builtin">unknown</span><span class="token punctuation">;</span> router<span class="token operator">:</span> RouterState<span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> AnyAction<span class="token operator">></span></code></pre>
    /xuqiongkai/ALTER MIT
    0
  • // reducers.js
    import { combineReducers } from 'redux'
    import { connectRouter } from 'connected-react-router'
    
    const createRootReducer = (history) => combineReducers({
      router: connectRouter(history),
      ... // rest of your reducers
    })
    export default createRootReducer
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">function</span> <span class="token generic-function"><span class="token function">combineReducers</span><span class="token generic class-name"><span class="token operator">&lt;</span><span class="token constant">S</span><span class="token operator">></span></span></span><span class="token punctuation">(</span>reducers<span class="token operator">:</span> ReducersMapObject<span class="token operator">&lt;</span><span class="token constant">S</span><span class="token punctuation">,</span> <span class="token builtin">any</span><span class="token operator">></span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token generic-function"><span class="token function">Reducer</span><span class="token generic class-name"><span class="token operator">&lt;</span>CombinedState<span class="token operator">&lt;</span><span class="token constant">S</span><span class="token operator">>></span></span></span> <span class="token punctuation">(</span><span class="token operator">+</span><span class="token number">2</span> overloads<span class="token punctuation">)</span> <span class="token keyword">import</span> combineReducers</code><div class="typing-tooltip-markup">Turns an object whose values are different reducer functions, into a single reducer function. It will call every child reducer, and gather their results into a single state object, whose keys correspond to the keys of the passed reducer functions.<br><br><em>@template</em> — S Combined state object type.<br><br><em>@param</em> <code>reducers</code><br><br>An object whose values correspond to different reducer functions that need to be combined into one. One handy way to obtain it is to use ES6 <code>import * as reducers</code> syntax. The reducers may never return undefined for any action. Instead, they should return their initial state if the state passed to them was undefined, and the current state for any unrecognized action.<br><br><em>@returns</em><br><br>A reducer function that invokes every reducer inside the passed object, and builds a state object with the same shape.</div></pre>
    Docs
    0
  • // Bring your own HTTP! This makes it easier to add SSL and allows the user to
    // choose between different HTTP implementations, such as HTTP/2.
    const http = require('http')
    const fortune = require('fortune')
    const fortuneHTTP = require('fortune-http')
    
    const store = fortune(...)
    
    // The `fortuneHTTP` function returns a listener function which does
    // content negotiation, and maps the internal response to a HTTP response.
    const listener = fortuneHTTP(store)
    const server = http.createServer((request, response) =>
      listener(request, response)
      .catch(error => { /* error logging */ }))
    
    store.connect().then(() => server.listen(1337))
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">module</span> <span class="token string">"http"</span> <span class="token keyword">import</span> http</code><div class="typing-tooltip-markup">To use the HTTP server and client one must <code>require('http')</code>.<br><br>The HTTP interfaces in Node.js are designed to support many features of the protocol which have been traditionally difficult to use. In particular, large, possibly chunk-encoded, messages. The interface is careful to never buffer entire requests or responses, so the user is able to stream data.<br><br>HTTP message headers are represented by an object like this:<br><br><pre class="code js"><code class="language-js">{ 'content-length': '123', 'content-type': 'text/plain', 'connection': 'keep-alive', 'host': 'mysite.com', 'accept': '*' }</code></pre><br><br>Keys are lowercased. Values are not modified.<br><br>In order to support the full spectrum of possible HTTP applications, the Node.js HTTP API is very low-level. It deals with stream handling and message parsing only. It parses a message into headers and body but it does not parse the actual headers or the body.<br><br>See <code>message.headers</code> for details on how duplicate headers are handled.<br><br>The raw headers as they were received are retained in the <code>rawHeaders</code>property, which is an array of <code>[key, value, key2, value2, ...]</code>. For example, the previous message header object might have a <code>rawHeaders</code>list like the following:<br><br><pre class="code js"><code class="language-js">[ 'ConTent-Length', '123456', 'content-LENGTH', '123', 'content-type', 'text/plain', 'CONNECTION', 'keep-alive', 'Host', 'mysite.com', 'accepT', '*' ]</code></pre><br><br><em>@see</em> — <a href="https://github.com/nodejs/node/blob/v16.9.0/lib/http.js">source</a></div></pre>
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples