Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
}
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');
});
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 {