How to use the httpsnippet.availableTargets function in httpsnippet

To help you get started, we’ve selected a few httpsnippet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kong / insomnia / packages / insomnia-app / app / ui / components / modals / generate-code-modal.js View on Github external
render() {
    const { cmd, target, client } = this.state;
    const { editorFontSize, editorIndentSize, editorKeyMap } = this.props;

    const targets = availableTargets();

    // NOTE: Just some extra precautions in case the target is messed up
    let clients = [];
    if (target && Array.isArray(target.clients)) {
      clients = target.clients;
    }

    return (
      
        Generate Client Code
github ErikWittern / openapi-snippet / index.js View on Github external
const formatTarget = function (targetStr) {
  const language = targetStr.split('_')[0]
  const title = capitalizeFirstLetter(language)
  const library = targetStr.split('_')[1]

  const validTargets = HTTPSnippet.availableTargets()
  let validLanguage = false
  let validLibrary = false
  for (let i in validTargets) {
    const target = validTargets[i]
    if (language === target.key) {
      validLanguage = true
      if (typeof library === 'undefined') {
        library = target.default
        validLibrary = true
      } else {
        for (let j in target.clients) {
          const client = target.clients[j]
          if (library === client.key) {
            validLibrary = true
            break
          }
github sumory / moklr / routes / mock.js View on Github external
var express = require('express');
var router = express.Router();
var HTTPSnippet = require('httpsnippet');
var util = require("util");
var logger = require('../lib/log.js').logger('mock');

var availableTargets = HTTPSnippet.availableTargets().reduce(function (targets, target) {
    if (target.clients) {
        targets[target.key] = target.clients.reduce(function (clients, client) {
            clients[client.key] = false;
            return clients
        }, {})
    } else {
        targets[target.key] = false;
    }

    return targets
}, {});

router.get('/create', function (req, res, next) {
    res.render('create');
});
github Kong / insomnia / packages / insomnia-app / app / ui / components / modals / generate-code-modal.js View on Github external
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import autobind from 'autobind-decorator';
import HTTPSnippet, { availableTargets } from 'httpsnippet';
import CopyButton from '../base/copy-button';
import { Dropdown, DropdownButton, DropdownItem } from '../base/dropdown';
import CodeEditor from '../codemirror/code-editor';
import Modal from '../base/modal';
import ModalBody from '../base/modal-body';
import ModalHeader from '../base/modal-header';
import ModalFooter from '../base/modal-footer';
import { exportHarRequest } from '../../../common/har';
import Link from '../base/link';

const DEFAULT_TARGET = availableTargets().find(t => t.key === 'shell');
const DEFAULT_CLIENT = DEFAULT_TARGET.clients.find(t => t.key === 'curl');
const MODE_MAP = {
  c: 'clike',
  java: 'clike',
  csharp: 'clike',
  node: 'javascript',
  objc: 'clike',
  ocaml: 'mllike',
};

const TO_ADD_CONTENT_LENGTH = {
  node: ['native'],
};

@autobind
class GenerateCodeModal extends PureComponent {

httpsnippet

HTTP Request snippet generator for *most* languages

Apache-2.0
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Popular httpsnippet functions