npm.io
6.0.1 • Published 1 month ago

sourcebin

Licence
MIT
Version
6.0.1
Deps
1
Size
20 kB
Vulns
0
Weekly
0
Stars
13

Sourcebin

Fast and simple package to get and create bins from sourcebin

Requirements

Node >=22.13

Getting

get(options)

import { get } from 'sourcebin';

const bin = await get({ key: 'qXO2NVhRc6' });

Options

Option Description Default Required
key The key to get n/a
fetchContent Should the bin content be fetched true

Creating

create(options)

import { create } from 'sourcebin';

const bin = await create({
	title: 'bin name',
	description: 'test bin',
	files: [
		{
			content: 'Hello World',
			language: 'text',
		},
	],
});
Options
Option Description Required
title Title of the bin
description Description of the bin
files Bin files - see below
File Options
Option Description Default Required
content Contents of the file n/a
language What language should the file be text

URL Helper

Constructs the long and short Sourcebin URL for a key.

const urlData = url('iQznILdZRP');

// or

const urlData = url('https://sourceb.in/iQznILdZRP');

This returns an object that looks like:

{
  key: 'iQznILdZRP',
  url: 'https://sourceb.in/iQznILdZRP',
  short: 'http://srcb.in/iQznILdZRP'
}

FAQ

Keywords