* great typescript module import refactor * refactor metamigo-cli so it is the entrypoint for the db, api, and worker
3 KiB
3 KiB
hapi-nextauth
This is a plugin for hapi.js that exposes NextAuth's database adapter via HTTP. Bring your own database.
Usage
import * as Hapi from "@hapi/hapi";
import Joi from "joi";
import NextAuthPlugin from "@digiresilience/hapi-nextauth";
import type { AdapterInstance } from "next-auth/adapters";
const server = new Hapi.Server();
// the validator must be registered before registering the plugin
await server.validator(Joi);
const nextAuthAdapterFactory: AdapterInstance = (request: Hapi.Request) => {
... instantiate your next auth adapter ...
}
// register the plugin
await server.register({
plugin: NextAuthPlugin,
options: {
// the only required parameter is a function that returns your implementation of the NextAuthAdapter
nextAuthAdapterFactory,
}});
Reference the next-auth typings for the adapter interface.
Options consist of:
nextAuthAdapterFactory- a function that returns your implementation of the NextAuthAdapter, it takes the Hapi Request as the sole argument.basePath- a string that all next auth endpoints will be served fromsharedSecret- the secret used for basic authentication to the nextauth endpointsvalidators- an object containingprofile- a Joi schema that validates a profileuser- a Joi schema that validates a useruserId- a Joi schema that validates a userIdsession- a Joi schema that validates a session
tags- tags to add to the endpoints
Defaults are defined in src/index.ts
Credits
Copyright © 2020-present Center for Digital Resilience
Contributors
Abel Luck |
|---|
License
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.