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

selina

v0.1.26

Published

Basic Typescript-Webserver

Downloads

33

Readme

Selina

Basic Webserver, developed with TypeScript on Node.js.

Contains the following two Classes:

  • Command
  • Server

Installation

Run npm i selina

Example

const selina = require("selina");
const server = new selina.Server(false, 0, response);
const p = server.getPrompt();
server.init();
server.addCommand(new selina.Command("ps", "Print Something", printSomething));
server.start();

function printSomething(){
    p.printLine();
    p.print("SOMETHING");
}

function response(req:Request):string{
    return "RESPONSE";
}

Note: This Example shows all Methods you need for basic Webserver-Functionality. The most Methods in the Server-Class are for internal use only.

Class: Server

Constructor

constructor(https:Boolean, port:number, responseFunction)

Example

let server = new Server(false, 80, anyFunction);

Methods

addCommand()

Adds a Command to the Server, if it not already exists.

Parameters:
  • command:Command
Use:
server.addCommand(new Command("command", "Description", anyFunction));

clearCommands()

Removes all Commands (incl. Default-Commands).

Parameters:
  • NONE
Use:
server.clearCommands();

execute()

Executes the Callback-Function of a Command.

Parameters:
  • command:string
Use:
server.execute("command");

exit()

Shutdown Application.

Parameters:
  • NONE
Use:
server.exit();

help()

Prints all Commands.

Parameters:
  • NONE
Use:
server.help();

init()

Removes all Commands and adds Default-Commands again.

Parameters:
  • NONE
Use:
server.init();

setPort()

Sets the Port. When "nr" is 0, the Default is 80 for HTTP or 8000 for HTTPS.

Parameters:
  • nr:number
Use:
server.setPort(80);

start()

Starts the Application

Parameters:
  • NONE
Use:
server.start();

startCLI()

Starts a Child-Process for CLI User-Input.

Parameters:
  • NONE
Use:
server.startCLI();

startListener()

Starts the Listener in HTTP- or HTTPS-Mode on defined Port.

Parameters:
  • NONE
Use:
server.startListener();

stopListener()

Stops the Listener.

Parameters:
  • NONE
Use:
server.stopListener();

Class: Command

Constructor

constructor(command:string, description:string, callback)

Example

let cmd = new Command("ps", "Print Something", printSomething);

Get & Set-Methods

command

Command-Text, e.g. "start" or "help". Type: string

description

Description-Text which is displayed on Command "help". Type: string

callback

Function to execute when typing a Command. Type: any (Must be a Function to work)