New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

better-auth-module

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-auth-module

Reusable authentication module with Better Auth integration and fallback mechanism

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Better Auth Module

A private, reusable authentication module with Better Auth integration and a robust fallback mechanism.

Features

  • 🔒 Seamless Better Auth integration
  • 🔄 Reliable fallback mechanism for offline development
  • 🛡️ Comprehensive error handling and logging
  • 💾 Memory-cached user data for improved reliability
  • 🔧 Easy installation and configuration
  • 📝 Detailed documentation and examples

Quick Start

# Install the module
npm install @heikodietze/better-auth-module

# Initialize in your project
npx better-auth-init

Integration

Express.js Application

const express = require('express');
const { setupAuth } = require('@heikodietze/better-auth-module');

const app = express();

// Initialize Better Auth with fallback
setupAuth(app, {
  betterAuthSecret: process.env.BETTER_AUTH_SECRET,
  betterAuthUrl: process.env.BETTER_AUTH_URL,
  dataPath: './data',
  cookieOptions: {
    secure: process.env.NODE_ENV === 'production',
    maxAge: 30 * 24 * 60 * 60 * 1000 // 30 days
  }
});

// Your routes here
app.get('/', (req, res) => {
  res.send('Hello World');
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

Configuration Options

OptionDescriptionDefault
betterAuthSecretBetter Auth secret keyRequired
betterAuthUrlBetter Auth API URLhttps://api.better-auth.com
dataPathPath to store fallback user data./data
cookieOptionsOptions for session cookiesSee documentation
enableFallbackEnable fallback mechanismtrue
logLevelLogging verbosityinfo

Best Practices & Lessons Learned

  • Memory Caching: The module uses in-memory caching alongside file storage to prevent data loss and improve reliability.
  • Error Handling: Specific error messages for different operations (signup vs signin) to avoid user confusion.
  • File Operations: Atomic file operations with verification steps ensure data integrity.
  • Session Management: Secure cookie-based sessions with proper HTTP security flags.

Advanced Usage

See the documentation for advanced usage examples and customization options.

License

Private - All Rights Reserved

Keywords

authentication

FAQs

Package last updated on 13 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts