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

public-server-api

v1.0.5

Published

The client-side JS module of PublicServer API is used to implement some backend functions in the front-end, such as sending real HTTP requests instead of AJAX

Downloads

59

Readme

PublicServer Client

Chinese 简体中文
↑I wrote it in my parent language, so translating it may actually be easier to understand.!
The client of PublicServer API.
My english is not well, i am sorry.

what is PublicServer API

PublicServer is an free API for all front-end and localapp coder to do some thing that must have an server, like as send an truly http request or write a vote site.
The all func of PublicServer isnt need an key or signup at now, so u don't need do anything. Just request it, that's no problem.
PublicServer API is currently maintained by N-Project( it's formed by me ), but infact this project just has one coder that's my own(host use my vercel, I am no full money to buy an host server because I am a student), my friends provide that domain:(.
If u like this project, u can sponsor me on WeChat with CNY:(

Install

In the version 1.0.3, you can use this module on both browser and node runtime.
There are two ways to install this module.
Use npm cmd

npm install public-server-api

You can also manually download this module from CDN.
Use on browser and use CDN to install:

<script src="https://publicserver.n-project.us.kg/client/client.js"></script>

Document

~~Do you think I talk too mach, I think so~~
Let's go, my favorite func that is We can use API to send truly http request now.
Here is an simple example

(async function(){
  var myserver = new PublicServer()
  alert( await myserver.cat( "https://example.com" ))
  // a easy way to get site body as string
  
  // The another way for request site, it's same as H5 `fetch` API
  var response = await myserver.request( "https://example.com" )
  alert( await response.text() )
})()

In version 1.0.3, the cat method supports sending post requests with datas. For example

var text = await myserver.cat( "https://example.com", "POST", {
  name : "114514"
} )

And I made a mail api (SMTP), that will help u send an email in front-end

var myserver = new PublicServer()
myserver.mail( {
   host: "smtp.xxx.com",
   uname: "[email protected]",
   // from : "[email protected]",
   // ↑ If don't set this option, that will be samed as uname
   pw: "password",
   subject: "TestEmailAPI",
   to: "[email protected]",
   body: "<b>body of your mail with html support</b>"
}).then( ( data ) => {
   if( data.statu === "error" ){
      console.table( data.error )
   } else {
      console.log( data.statu )
   }
})

If u want to get your page request params from url. u can use value params

console.table( new PublicServer().params )
// If u use node runtime, This value will get params from cmd line arguments.

dns API and a simple socket api example

var myserver = new PublicServer()
var readdt = await readSocket(
  (await dnsParse( "example.com" )
  /* 返回 domain(域名) 和 data */ ).data[0] + ":8080" /*,
  1 默认为1, 表示在第多少次的时候返回数据*/
)

if( readdt.statu == error ){
  console.table( readdt.error )
} else {
  console.table( readdt.data )
  // 返回data是一个数组,表示接听到的内容,数组每个成员都包含string与buffer(数组)两个对象
}

Ip API example

var myserver = new PublicServer()
// If this way always return 127.0.0.1, please use `new PublicServer( "https://pubilc-server-guw1n1jm4-love-kogasas-projects.vercel.app" )`
myserver.ip().then( dt => console.log( dt.ipv4 ) )
// "dt" is an object contain ip and ipv4

Counter API example.
This api can't run with default api server now, because I use vercel for API server, server will run on read-only filesystem

var myserver = new PublicServer()
myserver.number( false ).then( console.table )
// get all counter
myserver.number( true, "test" ).then( console.log )
// get counter by id "test"
myserver.number( true, "xxx.xxx.com testnumber", 5 ).then( console.log )
// Register a counter(if this id isnt be registered) and increase 5

By the way, please use "xxx.com id" like format to register your counter id. Because emmm... u know.

At present, there are only these contents, but I will gradually add more. awa