npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rstd

v0.11.0

Published

Language/Interpreter for easily defining and running requests to an http server.

Downloads

9

Readme

crates.io npm version

rested (Experimental)

Language/Interpreter for easily defining and running requests to an http server.

Why?

To easily test apis during development, and the Postman experience is slow. As someone who edits text files professionally, it seems natural to have a DSL for this usecase as well. It's a much better workflow to use curl commands in shell scripts than clicking around a GUI. Many developers have great success with that strategy, and it's powerful because linux (piping files) is powerful. But it could be simpler still to have a DSL for something more powerful than curl. Hence this experiment.

Demo

https://github.com/Gnarus-G/rested/assets/37311893/b03e5d14-658c-4086-8075-f518d6e8b6a1

Install (the CLI Interpreter)

From crates.io

cargo install rested

or from npmjs.com

npm install -g rstd

Usage

Language/Interpreter for easily defining and running requests to an http server.

Usage: rstd [OPTIONS] <COMMAND>

Commands:
  run         Run a script written in the language
  fmt         Format a script written in the language
  scratch     Open your default editor to start editing a temporary file
  snap        Generate a static snapshot of the requests with all dynamic values evaluated
  env         Operate on the environment variables available in the runtime. Looking into the `.env.rd.json` in the current directory, or that in the home directory
  completion  Generate a completions file for a specified shell
  lsp         Start the rested language server
  config      Configure, or view current configurations
  help        Print this message or the help of the given subcommand(s)

Options:
  -l, --level <LEVEL>  Set log level, one of trace, debug, info, warn, error [default: info]
  -h, --help           Print help
  -V, --version        Print version

Write a script, for example

// assuming file name requests.rd
@log
get https://jsonplaceholder.typicode.com/todos/1

Run it with the CLI.

rstd run requests.rd

Features

Global constants

set BASE_URL "http://localhost:8080/api/v2"

setting BASE_URL like so, allows you to be able to make request to just pathnames

// This will make a request to "http://localhost:8080/api/v2/potatoes"
get /potatoes

Let bindings

let token = "<token>"

// template string literals
let bearer_token = `Bearer ${token}`

Defining request headers and request body

post /potatoes {
   header "Authorization" "Bearer token"

   // json expressions
   body json({
       neet: 1337,
       stuff: [1, true, "three"]
   })
}

Reading environment variables

set BASE_URL env("base-url")

post /tomatoes {
   header "Authorization" env("auth-token")
   body env("data")
}

Setting environment variables (CLI)

rstd env set <name> <value>

It's also possible to namespace the variables.

rstd env set <name> <value> -n <namespace>
Operate on the environment variables available in the runtime. Looking into the `.env.rd.json` in the current directory, or that in the home directory

Usage: rstd env [OPTIONS] <COMMAND>

Commands:
  show  View environment variables available in the runtime
  edit  Edit environment variables in your default editor
  set   Set environment variables available in the runtime
  ns    Operate on the variables namespaces available in the runtime
  help  Print this message or the help of the given subcommand(s)

Options:
      --cwd            Set to look at the `.env.rd.json` file in the current working directory. Otherwise this command and its subcommands operate on the `.env.rd.json` file in your home directory
  -l, --level <LEVEL>  Set log level, one of trace, debug, info, warn, error [default: info]
  -h, --help           Print help

Reading files

post /tomatoes {
   body read("data.json")
}

Attributes

// prints response body to stdout
@log
get /yams
// prints response body to a file
@log("output/yams.json")
get /yams

There are more, but I'm kind of ashamed of these attributes, so let's stop.

Neovim Plugin

For Syntax Highlighting and Intellisense with the lsp, use restedlang.nvim