@sheetbase/api-key-server
v0.0.11
Published
Sheetbase middleware to authorize with the API Key.
Downloads
2
Maintainers
Readme
Sheetbase Module: @sheetbase/api-key-server
Sheetbase middleware to authorize with the API Key.
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
Docs homepage: https://sheetbase.github.io/api-key-server
API reference: https://sheetbase.github.io/api-key-server/api
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.