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

@adrianobrito/vaporwave

v0.0.6

Published

JSON Server with self-implemented REST API's

Downloads

11

Readme

Vaporwave is a HTTP server capable of support self-implemented REST API's. You can use HTTP methods to send request to this server as it was a JSON database or a Firebase endpoint. It's provide the minimal necessary infrastructure to allow you adopt an UI-First development flow.

Installation

The package comes as CLI. So you need to install it globally via npm. The current version is not definitive release. You can check the roadmap to first candidate release.

$ npm install -g @adrianobrito/vaporwave 

Usage

After installation, it's necessary to execute a command to startup server. If it's successfull started you will have a output like that below on your command shell.

$ vaporwave
Vaporwave is running on port 8000
  _    _
  |   /
--|--/-----__------__----__---)__-----------__---------__-
  | /    /   )   /   ) /   ) /   )| /| /  /   ) | /  /___)
__|/____(___(___/___/_(___/_/_____|/_|/__(___(__|/__(___ _
               /
              / 

In order to show the usage of vaporwave server, it will be used curl to illustrate the behavior of that server.

Basically the server receive HTTP Requests on any endpoint, but do the REST task related with the HTTP method used on that particular endpoint. If you do a HTTP GET on api/users endpoint, the server will list all the data contained on api/users endpoint, like it was supposed to do on a RESTful application. Let's check an example:

$ curl -X GET "http://localhost:8000/api/users"
[]

When you startup the server throught vaporwave command, you can access it using port 8000. When you perform a simple HTTP GET on api/users the server gets the current state of related collection in this endpoint. The previous example returned a empty array, because the related collection with api/users is empty. In order to change the state of this endpoint, let's do HTTP POST request throught curl.

$ curl -X POST 
	-H "Content-Type: application/json" 
	-d '{"name":"Adriano Brito", "username": "adrianobrito", "password" : "qwe123"}' 
	"http://localhost:8000/api/users"
{"name":"Adriano Brito","username":"adrianobrito","password":"qwe123","id":2323}

As a response it was given a JSON that was sent with an id property with some random number. If a new HTTP GET request is performed on api/users endpoint you will get the following output:

$ curl -X GET http://localhost:8000/api/users
[{"name":"Adriano Brito","username":"adrianobrito","password":"qwe123","id":2323}]

It's easy to check that the collection related with api/users is not empty anymore.

The returned object from HTTP POST request has an id property. This id allows you to create a request to that specific object using api/users/{id} endpoint like it's shown below:

$ curl -X GET "http://localhost:8000/api/users/2323"
{"name":"Adriano Brito","username":"adrianobrito","password":"qwe123","id":2323}

In order to update this unique object, it's necessary dispacth a HTTP PUT against vaporwave in some specific endpoint, sending the new version of the resource as request body, like below:

$ curl -X PUT 
	-H "Content-Type: application/json" 
	-d '{"name":"Adriano Brito Bispo","username":"adrianobritobispo","password":"qwe123","id":2323}' 
	"http://localhost:8000/api/users/2323"
{"name":"Adriano Brito Bispo","username":"adrianobritobispo","password":"qwe123","id":2323}

$ curl -X GET "http://localhost:8000/api/users/2323"
{"name":"Adriano Brito Bispo","username":"adrianobritobispo","password":"qwe123","id":2323}

It's easy to see that the object related with api/users/2323 endpoint was updated with the object sent in HTTP PUT request body.

If you need to remove a specific object from server, you can perform a HTTP DELETE with an ID in request path, like is shown below:

$ curl -X DELETE "http://localhost:8000/api/users/2323"
{"name":"Adriano Brito Bispo","username":"adrianobritobispo","password":"qwe123","id":2323}

$ curl -X GET "http://localhost:8000/api/users/2323"

After execute an HTTP DELETE request in api/users/2322 endpoint, the server will remove that specific object from your internal database. It's shown on subsequent HTTP GET request.

Contribute

If you want to help on development of vaporwave first release, you can check our issues here. Feel free to create a pull request or suggest some new changes to be added to the first release proposal.