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

@waiter/domain

v7.0.0

Published

Waiter Domain Library for Node.js

Downloads

43

Readme

Waiter Domain Library for Node.js

npm (scoped) CircleCI Coverage Status Known Vulnerabilities npm

Table of contents

Background

  • チケット購入サイトへのアクセスがある量感を超えると、システムで受け止め切ることは簡単でない。
  • インフラにコストをかけることで解決するのは簡単だが、コストに限度のないケースは少ない。
  • 外部サービスと連携するシステムをつくる以上、外部サービス側の限度を考慮する必要がある。
  • アプリケーション(ソフトウェア)のレベルでできる限りのことはしたい。

Requirement

  • 本システムにかかる負荷と、フロントエンドアプリケーション側のインフラ(ウェブサーバー、DBサーバー)への負荷が分離していること。
  • 厳密にコントロールできる、というよりは、それなりに有効であることが大事。
  • フロントウェブサーバーに負荷をかけられないため、クライアントサイドから呼び出せることが必須。

Specification

許可証の暗号化と検証


                                                         ........................
                                                         :                      :
                                                         :  WAITER              :
                                                         :                      :
+--------------+                                         :  +----------------+  :
|              |--(A)------ Passport Request -------------->|                |  :
|  End-user    |           + scope                       :  |  Passport      |  :
|  Local       |                                         :  |  Issue         |  :
|              |<-(B)------ Encoded Passport ---------------|  Server        |  :
|              |                                         :  |                |  :
|              |                                         :  +--------■■------+  :
|              |                                         :           ■■         :
|              |                                         :           ■■         :
|              |                                         :         SECRET       :
|              |                                         :(environment variable):
|              |                                         :           ■■         :
|              |                                         :           ■■         :
|              |                                   +-----------------■■------------+
|              |                                   |     :                      :  |
|              |                                   |  Client                    :  |
|              |                                   |  Frontend                  :  |
|              |                                   |  Server                    :  |
|              |                                   |     :                      :  |
|              |                                   |     :  +----------------+  :  |
|              |--(C)------ Verify Request ---------------->|                |  :  |
|              |            + encoded passport     |     :  |  Token         |  :  |
|              |                                   |     :  |  Verifier      |  :  |
|              |<-(D)------ Verify Result ------------------|                |  :  |
|              |                                   |     :  |                |  :  |
|              |                                   |     :  +----------------+  :  |
|              |                                   |     :                      :  |
+--------------+                                   +-------------------------------+
                                                         :                      :
                                                         :                      :
                                                         ........................

登場用語


発行規則

  • 許可証発行規則。事前にWAITERに環境変数として登録。

| field | type | description | | ---------------------------------------- | ------ | ---------------------------- | | scope | string | スコープ | | aggregationUnitInSeconds | number | 許可証数集計単位(秒) | | threshold | number | 単位時間当たりの許可証数閾値 | | unavailableHoursSpecifications | array | サービス休止時間帯設定リスト | | unavailableHoursSpecifications.startDate | string | サービス休止開始日時 | | unavailableHoursSpecifications.endDate | string | サービス休止終了日時 |

{
    "scope" : "mcdonalds",
    "aggregationUnitInSeconds" : 300,
    "threshold": 120,
    "unavailableHoursSpecifications":[
        {"startDate":"2017-11-10T09:00:00Z","endDate":"2017-11-10T09:30:00Z"}
    ]
}

許可証発行単位

  • スコープごとに発行単位が作成される。許可証の発行を依頼されると、単位ごとに発行数を集計しながら発行を試みる。

| field | type | description | | ---------------- | ------ | ------------------------ | | identifier | string | 許可証発行単位識別子 | | validFrom | number | いつから有効な発行単位か | | validThrough | number | いつまで有効な発行単位か | | numberOfRequests | number | 許可証発行リクエスト数 |

許可証

  • 発行者が発行する許可証は鍵によって暗号化される。
  • 発行依頼者は鍵を事前に設定することで暗号化された許可証を検証し、許可するかどうかを判断する。

| field | type | description | | --------- | ---------- | ------------------------ | | iss | string | 発行者 | | iat | number | 発行unixタイムスタンプ | | exp | number | 期限unixタイムスタンプ | | scope | string | スコープ | | issueUnit | IIssueUnit | 発行単許可証発行単位位名 |

{
  "scope": "scope",
  "issueUnit": {
    "identifier": "scope:1511059500",
    "validFrom": 1511059500,
    "validThrough": 1511059800,
    "numberOfRequests": 1
  },
  "iat": 1511059610,
  "exp": 1511059910,
  "iss": "https://waiter.example.com"
}

Usage

Environment variables

| Name | Required | Value | Purpose | | ------------------------ | -------- | --------------- | --------------- | | DEBUG | false | waiter-domain:* | Debug | | WAITER_PASSPORT_ISSUER | true | | Passport issuer | | WAITER_SECRET | true | | secret for sign |

Code Samples

example