Skip to content

v1.0.0

Choose a tag to compare

@angga7togk angga7togk released this 21 Jul 15:01
· 25 commits to main since this release
9c206e0

πŸš€ GamanJS Release Notes

⚠️ Node.js Version Requirement

Important: This version of GamanJS requires Node.js >= v18.20.8. Please update your Node.js installation if you're using an older version.

πŸ› Bug Fixes

Fixed Method Route Responsiveness Issue

Fixed a critical issue where method routes were not responding correctly to different HTTP methods.

Before (Broken):

routes: {
  "/": {
    GET: () => "OK",
    POST: () => "OK (POST)"
  }
}

Previously, making a POST request would incorrectly execute the GET handler instead of the POST handler. This has been resolved.

Now (Fixed): All HTTP methods now correctly route to their respective handlers.

✨ New Features

Strict Route Matching

Introduced strict route matching functionality for more precise URL handling.

defineBlock({
  strict: true
})
  • strict: true - Routes must match exactly, including trailing slashes (e.g., /dashboard/user/ requires the trailing slash)
  • strict: false or omitted - Flexible matching, works with or without trailing slashes

Examples:

// Strict mode - must include trailing slash
"/dashboard/user/" βœ… matches
"/dashboard/user"  ❌ doesn't match

// Non-strict mode - both work
"/dashboard/user/" βœ… matches  
"/dashboard/user"  βœ… matches

Session Helper Context Support

Added comprehensive session management with pluggable storage drivers.

New Session API:

// Set session data
await ctx.session.set('user_id', '12345');
await ctx.session.set('user_data', { name: 'John', role: 'admin' });

// Get session data  
const userId = await ctx.session.get('user_id');
const userData = await ctx.session.get('user_data');

// Check if session exists
const hasUser = await ctx.session.has('user_id');

// Delete session data
await ctx.session.delete('user_id');

Supported Storage Drivers:

  • cookies - Stateless signed cookies (default)
  • memory - In-memory storage for development
  • file - File-based storage
  • redis - Redis storage for production
  • sql - SQLite database storage
  • mongodb - MongoDB NoSQL storage

Usage Example:

import { session } from 'gaman/integrations';

// Basic setup with cookies
integrations: [session()]

// With Redis
integrations: [session({
  driver: { type: 'redis', url: 'redis://localhost:6379' },
  secret: 'your-secret-key',
  maxAge: 3600
})]

For more details, see merge tag [#13](../../pull/13).

πŸ“¦ Package Consolidation

Deprecated Standalone Packages

The following standalone packages have been deprecated and are now built into GamanJS core:

  • @gaman/cors β†’ gaman/cors
  • @gaman/ejs β†’ gaman/ejs
  • @gaman/basic-auth β†’ gaman/basic-auth
  • @gaman/nunjucks β†’ gaman/nunjucks
  • And other @gaman/* packages

Migration Guide:

// OLD - Deprecated
import cors from '@gaman/cors';
import ejs from '@gaman/ejs';
import basicAuth from '@gaman/basic-auth';

// NEW - Built-in
import cors from 'gaman/cors';
import ejs from 'gaman/ejs';
import basicAuth from 'gaman/basic-auth';

Benefits:

  • βœ… Reduced dependency management
  • βœ… Better version compatibility
  • βœ… Simplified installation process
  • βœ… Faster startup times

πŸ”„ Breaking Changes

  • Node.js Version: Minimum required version is now v18.20.8
  • Package Imports: Update import statements from @gaman/* to gaman/*

πŸ“ˆ Improvements

  • Enhanced route matching accuracy
  • Better session management capabilities
  • Streamlined package architecture
  • Improved developer experience