@softeneers/auth
v0.1.0
Published
Authentication for Softeneers projects: a configured better-auth instance plus Express/Node helpers.
Downloads
75
Readme
@softeneers/auth
Authentication built on better-auth: a configured server instance plus Express/Node helpers.
Usage
import { createAuth, toNodeHandler, getSession } from "@softeneers/auth";
export const auth = createAuth({
database: pool, // a mysql2 Pool (e.g. from your DB layer), Kysely dialect, or adapter
secret: env.AUTH_SECRET,
baseURL: env.BASE_URL,
});
// Express: mount better-auth's routes
app.all("/api/auth/*", toNodeHandler(auth));
// Read the current session in a route
app.get("/me", async (req, res) => {
const session = await getSession(auth, req.headers);
res.json(session); // null when unauthenticated
});API
createAuth(options)— better-auth instance; email+password enabled by default, every option overridable.getSession(auth, headers)— session payload (ornull) from Node headers.- Re-exports
toNodeHandler,fromNodeHeaders,BetterAuthError, and theAuth/AuthOptionstypes.
Pair with @softeneers/db for the database and
@softeneers/env to validate AUTH_SECRET / BASE_URL.
A login/register UI for the next-fullstack template is tracked in the roadmap.
