@sheetbase/api-key-server
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

Sheetbase Module: @sheetbase/api-key-server

Sheetbase middleware to authorize with the API Key.

Build Status Coverage Status NPM License clasp Support me on Patreon PayPal Ask me anything

Install

Using npm: npm install --save @sheetbase/api-key-server

import * as ApiKey from "@sheetbase/api-key-server";

As a library: 1NulS_tPHLm401X7Km_ONKgtRK-VHnC5ODmNZ1sMt0QgXuDgtffxJ-Zzv

Set the Indentifier to ApiKeyModule and select the lastest version, view code.

declare const ApiKeyModule: { ApiKey: any };
const ApiKey = ApiKeyModule.ApiKey;

Usage

Examples

import * as Sheetbase from "@sheetbase/core-server";
import * as ApiKey from "./public_api";

const key = "my_api_key";

function load_() {
  return Sheetbase.sheetbase();
}

export function example1(): void {
  const Sheetbase = load_();

  Sheetbase.Router.get("/auth", ApiKey.middleware({ key }), (req, res) => {
    res.send("I have it!");
  });

  Logger.log("[Not executable] Per route middleware.");
}

export function example2(): void {
  const Sheetbase = load_();

  Sheetbase.Router.use(ApiKey.middleware({ key }));

  Sheetbase.Router.get("/auth", (req, res) => {
    res.send("I have it!");
  });

  Sheetbase.Router.post("/auth", (req, res) => {
    res.send("I have it!");
  });

  Logger.log("[Not executable] Global use middleware.");
}

License

@sheetbase/api-key-server is released under the MIT license.

Package Sidebar

Install

npm i @sheetbase/api-key-server

Weekly Downloads

2

Version

0.0.11

License

MIT

Unpacked Size

27 kB

Total Files

17

Last publish

Collaborators

  • lamnhan