Skip to main content

lastlogin auth for smallweb

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
82%
Published
2 months ago (0.5.13)

Lastlogin Authentication

Usage in smallweb

First wrap your endpoint in the lastlogin middleware.

// ~/smallweb/lastlogin-example/main.ts
import { lastlogin } from "jsr:@pomdtr/lastlogin";

export default {
  fetch: lastlogin((req: Request) => {
    const email = req.headers.get("X-Lastlogin-Email");
    return new Response(`Hello, ${email}!`);
  }),
};

Then either set some options in your .env file:

# ~/smallweb/.env
LASTLOGIN_SECRET_KEY=my-secret-key
LASTLOGIN_EMAIL=pomdtr@gmail.com
LASTLOGIN_PROVIDER=google

or pass them as an object to the lastlogin function:

// ~/smallweb/lastlogin-example/main.ts
import { lastlogin } from "jsr:@pomdtr/lastlogin";

export default {
  fetch: lastlogin((req: Request) => {
    const email = req.headers.get("X-Lastlogin-Email");
    return new Response(`Hello, ${email}!`);
  }, {
    provider: "google",
    email: "pomdtr@gmail.com"
  })
};

A list of supported options can be found in the package documentation.

Add Package

deno add jsr:@pomdtr/lastlogin

Import symbol

import * as lastlogin from "@pomdtr/lastlogin";

---- OR ----

Import directly with a jsr specifier

import * as lastlogin from "jsr:@pomdtr/lastlogin";

Add Package

npx jsr add @pomdtr/lastlogin

Import symbol

import * as lastlogin from "@pomdtr/lastlogin";

Add Package

yarn dlx jsr add @pomdtr/lastlogin

Import symbol

import * as lastlogin from "@pomdtr/lastlogin";

Add Package

pnpm dlx jsr add @pomdtr/lastlogin

Import symbol

import * as lastlogin from "@pomdtr/lastlogin";

Add Package

bunx jsr add @pomdtr/lastlogin

Import symbol

import * as lastlogin from "@pomdtr/lastlogin";