@scalar/snippetz
TypeScript icon, indicating that this package has built-in type declarations

0.2.19 • Public • Published

Snippetz

Version Downloads License Discord

A modern way to generate HTTP request examples for different languages and libraries.

Installation

npm install @scalar/snippetz

Usage

import { snippetz } from '@scalar/snippetz'

const snippet = snippetz().print('node', 'undici', {
  url: 'https://example.com',
})

/* Output */

// import { request } from 'undici'
//
// const { statusCode, body } = await request(
//   'https://example.com',
// )

API

Get all plugins

import { snippetz } from '@scalar/snippetz'

const snippet = snippetz().plugins()

/* Output */

// [
//   {
//     target: 'node',
//     client: 'undici',
//   }
// ]

Check if a plugin is loaded

import { snippetz } from '@scalar/snippetz'

const snippet = snippetz().hasPlugin('node', 'undici')

/* Output */

// true

Lean usage

You can also just use one specific plugin to keep your bundle size small.

import { nodeUndici } from '@scalar/snippetz/plugins/node/undici'

const result = nodeUndici.generate({
  url: 'https://example.com',
})

console.log(source)

// import { request } from 'undici'

// const { statusCode, body } = await request(
//   'url': 'https://example.com',
// )

Community

We are API nerds. You too? Let’s chat on Discord: https://discord.gg/scalar

License

The source code in this repository is licensed under MIT.

Readme

Keywords

none

Package Sidebar

Install

npm i @scalar/snippetz

Weekly Downloads

39,623

Version

0.2.19

License

MIT

Unpacked Size

244 kB

Total Files

382

Last publish

Collaborators

  • amritkahlon
  • cameronrohani
  • marclave
  • tommastro
  • scalar_geoff
  • hwkr
  • mason-little
  • hanspagel