@sheetbase/auth-api-key-serverdeprecated

Sheetbase middleware to authorize with the API Key.

Usage no npm install needed!

<script type="module">
  import sheetbaseAuthApiKeyServer from 'https://cdn.skypack.dev/@sheetbase/auth-api-key-server';
</script>

README

Sheetbase Module: @sheetbase/auth-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/auth-api-key-server

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

As a library: 1NulS_tPHLm401X7Km_ONKgtRK-VHnC5ODmNZ1sMt0QgXuDgtffxJ-Zzv

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

declare const AuthApiKeyModule: { AuthApiKey: any };
const AuthApiKey = AuthApiKeyModule.AuthApiKey;

Usage

Examples

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

const key = "my_api_key";

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

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

  Sheetbase.Router.get("/auth", AuthApiKey.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(AuthApiKey.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/auth-api-key-server is released under the MIT license.