0.3.0 • Published 5 months ago

@logi.one/stormfree v0.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Storm Free

Storm Free is an ultra-lightweight (and forever free) Rest API tester for node using terminal as output.

Getting Started

Install Storm Free :

npm install --save-dev @logi.one/stormfree

Create a Javascript (or Typescript) source file with a request to your API :

import { get } from '@logi.one/stormfree'

await get('https://api.github.com/users/logione')

Run your request :

node request.mjs

Get the output in the terminal :

Request output

Examples

Make a simple GET request :

await get('https://my-api/users')

Make a request with url search parameters :

// using object
await get('https://my-api/users', { search: { active: true, name: 'john doe' }})

// using array
await get('https://my-api/users', { search: [['active', 'true'], ['name', 'john%20doe']]})

// using URLSearchParams
await get('https://my-api/users', { search: new URLSearchParams({ active: 'true', name: 'john doe' }) })

// or using string
await get('https://my-api/users', { search: 'active=true&name=john%20doe' })

// all equal the following request
await get('https://my-api/users?active=true&name=john%20doe')

POST json data :

await post('https://my-api/users', { json: { username: 'john@mail.com', name: 'John Doe' }})

Make a DELETE request with a bearer token :

await del('https://my-api/users/1', { token: 'my-bearer-token' })

PUT XML data :

await put('https://my-api/users/1', { 
    headers: { 'Content/type': 'application/xml' },
    body: '<active>false</active>'
})

Prevent request and status to be printed :

await get('https://my-api/users',
    { print: { request: false, status: false, headers: true, body: true } }
)

Prevent any printing :

await get('https://my-api/users', { print: false })

Integration with test runners

Storm Free integrates nicely with test runners. Test runners can be useful to select which request to run.

import { it } from 'node:test'
import assert from 'node:assert'

it.only('Get all users', async () => {
    const { ok } = await get('https://my-api/users')
    assert(ok)
})

it('Try to delete a user without authenticiation', async () => {
    const result = await del('https://my-api/users/1')
    // result is the original Response from fetch 
    assert(!result.ok)
    assert(result.status === 401)
})

If you search a rest-client that doesn't print anything, you can use @logi.one/rest-client instead

0.3.0

5 months ago

0.2.0

5 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago