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

siuje

v1.1.0

Published

A tiny web-service for nas

Downloads

295

Readme

Siuje

A light framework for http backend server

What is Siuje

It is a very very tiny web server library, for Node.js.

How to Use

Startup the Server

// index.js
const siuje = require("siuje");
siuje.work({ host: "127.0.0.1", port: 3000 })

Schedule a Job

// index.js
const siuje = require("siuje");
siuje.when( "12:00" ).work( 
	async () => {
		// do some work here
	}
);
siuje.work({ host: "127.0.0.1", port: 3000 })

or

// index.js
const siuje = require("siuje");
const {second, minute, hour, day} = require("siuje/utime");
siuje.every( second(10) ).repeat(
	async () => {
		// do something
	}
)//.until( () => true|false );
siuje.work({ host: "127.0.0.1", port: 3000 })

Handle a HTTP Request

// index.js
const siuje = require("siuje");

// sample for middleware
const set_header = headers => {
	return (req, ctrl) => next => {
		ctrl( headers );
		return next(req, ctrl);
	}
}

siuje.meet("/test")
	.use( set_header({"Server": "siuje"}) )
	.serve( async (req, ctrl) => {
		return "hello, world";
	});

siuje.work({ host: "127.0.0.1", port: 3000 })

Middleware Presets

You can use siuje.seq to embed multiple middlewares into one middleware:

// index.js
const siuje = require("./siuje");

// sample for middleware
const set_header = headers => {
        return (req, ctrl) => next => {
                ctrl( headers );
                return next(req, ctrl);
        }
}

const my_headers = siuje.seq(
        set_header({"connection": "keep-alive"}),
        set_header({"access-control-allow-origin": "*"})
);

siuje.meet("/test")
        .use( set_header({"Server": "siuje"}) )
        .use( my_headers )
        .serve( async (req, ctrl) => {
                return "hello, world";
        });

siuje.work({ host: "127.0.0.1", port: 22181 })

How about bodyParser?

You should implement your middleware for body parser.

Hot to Deploy in Serverless?

You should use siujeless for serverless platform.

Detail for req/ctrl and next

  • req is the instance for http.IncomingMessage
  • next is only a function to run the next middleware
  • ctrl is a handler for building the response
    1. when you give a number to ctrl, it means that you want to set the http response status code
    2. when you give an object to ctrl, it means that you want to set the http response header
    3. when you give a string(json/query/else) to ctrl, it means that you want to set the http response mine type
    4. when you give an empty to ctrl, it means that you want to get the current status/header and mine type
    5. when you give an error object to ctrl, it will give a 500 for response
    6. when you give a function to ctrl, your function will be call with the http response object and a setter to custom your output