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

kubescript

v0.0.3

Published

[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

Downloads

5

Readme

KubeScript

experimental JavaScript Style Guide

KubeScript is a web application framework that helps you build scalable web application with plain JavaScript, connect with microservices written in any language.

npm i kubescript

preview

Synopsis

const App = require('kubescript')

// require docker images directly
const redisConfig = require('docker://redis')
const redisClient = require('redis')

let app = new App()

app.post('/register', function (ctx) {
  let {host, port} = redisConfig
  let c = redisClient.createClient({host, port})

  register(c)

  app.emit('user.registered')
  ctx.body = 'bar'
})

// event handling
app.on('user.registered', function (ctx) {
})

app.run()

Deploy this application to kubernetes with KUBESCRIPT_PHASE=build node index.js. One command, everything is automated.

For more example, see test-app.js.

Setup

To start, you need the following tools installed on your computer:

You also need a working kubernetes cluster. Currently, only v1.9.7 is tested.

note: When using GKE, you need to create a role first:

kubectl create clusterrolebinding cluster-admin-binding-$USER --clusterrole=cluster-admin --user=$(gcloud config get-value account).

CLI

Add a dependency
$ npx ks add [email protected]

API

new App()
const App = require('kubescript')
let app = new App()

Create a new KubeScript application.

app.get(path, handler), app.post(path, handler), app.put(path, handler), app.delete(path, handler)

Create a HTTP endpoint for specified method. handler is a koa handler.

Routing is done with koa-router.

app.on(event, handler)

Subscribe to an event.

app.emit(event, payload)

Emit an event with given payload.

app.run()

If KUBESCRIPT_PHASE environment variable is set to build, it will start building your application.

If not, start the application for runtime.

Config

You need to add settings to your package.json. Here's an example:

{
  "name": "YOUR_APP_NAME",
  "version": "0.0.1",
  ...
  "license": "ISC",
  "dependencies": {
    ...
  },
  "KubeScript": {
    "prefix": "gcr.io/spacer-184617/",
    "dependencies": {
      "foobar": {
        "version": "latest",
        "ports": [
          {
            "name": "http-server",
            "containerPort": 3000
          }
        ]
      },
      "redis": {
        "version": "4.0.9"
      }
    }
  },
}
  • KubeScript.prefix: The string to prepend to your application's docker image name. This is for pushing your image to the correct registry, such as Google Container Registry.
  • KubeScript.dependencies: The microservices your application depends on. The key is the corresponding docker image name. The value includes:
    • version: The version you want to use. KubeScript will look for image with specified version tag.
    • ports: The service's exposed port. KubeScript will try to find the EXPOSE port via inspecting the docker image by default.

License

The MIT License