Releases: LebCit/litenode
v4.7.0
LiteNode 4.7.0 Release Notes
🎉 What's New
Enhanced Template Engine Parsing
-
Fixed
@index,@keyandthisin expressions: You can now use loop context variables in conditional expressions{{#each posts}} {{#if @index > 0}} <!-- This now works! --> {{/if}} {{/each}} -
Fixed
#setin#eachloops: Variable assignment now works properly inside loop contexts{{#each items}} {{#set itemId = @index}} {{#set processedName = this.name | uppercase}} {{/each}}
New Array Manipulation Filters
Four powerful new filters for advanced array operations:
🔪 slice - Extract array portions
{{items | slice(1, 4)}} <!-- Get items 1-3 -->
{{items | slice(-3)}} <!-- Get last 3 items -->📥 take - Get first or last N items
{{posts | take(5)}} <!-- First 5 posts -->
{{comments | take(-3)}} <!-- Last 3 comments -->⏭️ skip - Skip first or last N items
{{items | skip(2)}} <!-- Skip first 2 -->
{{data | skip(-1)}} <!-- Skip last item -->📦 chunk - Split arrays into groups
{{#set rows = products | chunk(3)}}
{{#each rows}}
<div class="grid-row">
{{#each this}}
<div class="product">{{this.name}}</div>
{{/each}}
</div>
{{/each}}🚀 Use Cases
Pagination Made Easy
{{#set pageItems = allItems | slice(startIndex, endIndex)}}
{{#set hasMore = allItems | length > endIndex}}Grid Layouts
{{#set productRows = products | chunk(4)}}
{{#each productRows}}
<div class="product-row">
{{#each this}}
<div class="product-card">{{this.name}}</div>
{{/each}}
</div>
{{/each}}Featured Content
{{#set featured = posts | take(3)}}
{{#set recent = posts | take(-5)}}
{{#set regular = posts | skip(1)}}⚡ Performance Notes
- High Performance:
slice,take,skip,chunkare optimized for large arrays - Efficient Chaining: Combine filters for complex operations
- Memory Conscious: All new filters create shallow copies with minimal overhead
🛠️ Breaking Changes
None! This release is fully backward compatible.
📚 Documentation
Updated filters documentation with comprehensive examples and performance guidelines.
🔧 Bug Fixes
- Fixed template parsing errors when using
@index/@key/thisin expressions - Resolved
#setstatement parsing issues inside#eachloops - Improved error messages for invalid filter usage
Upgrade Command:
npm install [email protected]Full Changelog: v4.6.0...v4.7.0
v4.6.0
🚀 LiteNode v4.6.0 - Template Engine Enhancements
🆕 New Features
Enhanced Template Includes
- ✅
#includenow works inside#eachloops with proper context inheritance - ✅ Loop variables and current context automatically available in included templates
- ✅ Enables modular, reusable template components within iterations
Powerful Date Formatting
- 🌍 Locale Support: Custom month/weekday names for internationalization
- 🕐 Extended Tokens: 20+ format tokens (YYYY/yyyy, MMMM/MMM, dddd/ddd, A/a, Z)
- 🌐 Timezone Handling: Automatic timezone offset calculation and display
- ⏰ AM/PM Formatting: Both uppercase (A) and lowercase (a) meridiem support
- 🔄 Backward Compatible: Existing dateFormat usage continues to work
📖 Usage Examples
Template Includes in Loops
{{#each posts}}
{{ #include("./post-card.html") }} <!-- Now works! -->
{{/each}}Advanced Date Formatting
// French locale example
{{createdAt | dateFormat("dddd D MMMM YYYY", false, frenchLocale)}}
// → "mercredi 14 février 2024"
// Timezone-aware formatting
{{publishedAt | dateFormat("YYYY-MM-DD HH:mm Z", false)}}
// → "2024-02-14 08:30 +05:30"🔧 Breaking Changes
None - all changes are backward compatible
🛠️ Technical Improvements
- Enhanced StatementParser to handle includes within each loops
- Improved context inheritance in template evaluation
- Extended builtInFilters with comprehensive date formatting
This release showcases significant template engine improvements that make LiteNode much more powerful for building dynamic, internationalized web applications!
v4.5.0
LiteNode v4.5.0 Release – Advanced Frontmatter & Markdown Parsing
I'm thrilled to introduce major upgrades to SMP (Static Markdown Parser), LiteNode’s built-in markdown engine, now supporting complex frontmatter structures with effortless parsing!
✨ New Capabilities Example
With the enhanced FrontmatterParser, you can now handle deeply nested frontmatter like this:
---
categories:
- Development
- Parsing
- Docs
id: "1744396133932"
title: Documentation
slug: documentation
status: published
author:
name: Alice
hobbies: [read, swim, travel] # Mixed array syntax
age: 30 # Auto number conversion
skills: ["Markdown", "JS"] # Quoted strings
loves: Cats
achievements:
- Oops, it worked!
- Fixed it. No idea how?
- Blamed the intern. She is the intern!
tags: [js, yaml, node] # Simple arrays
dates:
createdAt: "2025-04-11T18:28:53.932Z" # Auto Date parsing
updatedAt: 2025-04-12T14:12:07.086Z # Unquoted ISO dates
featuredImage:
url: /images/sea.jpg # Nested objects
alt: "" # Empty string handling
---Key Improvements:
✅ Nested Objects
✅ Mixed Arrays (bracket [a, b] and hyphen - a syntax)
✅ Auto-Type Conversion (numbers, dates, booleans)
✅ Robust String Handling (quoted/unquoted, empty values)
✅ Deep Indentation Support (for readability)
🚀 Why Upgrade?
- No More Workarounds – Parse complex metadata without manual preprocessing.
- Strict Yet Flexible – Handles edge cases (e.g., mixed quotes, trailing commas).
- Faster Debugging – Detailed errors with line numbers for malformed YAML.
npm install [email protected]🔍 Under the Hood
- Rewritten
FrontmatterParserwith indentation-aware parsing. - New
NestedStackclass for hierarchical state management. - 100% backward-compatible – your existing markdown files keep working!
I appreciate your feedback and contributions - enjoy the new features!
v4.4.0
LiteNode 4.4.0 Release
I'm excited to announce the release of LiteNode 4.4.0, which introduces several powerful new features and enhancements to make your development experience even smoother.
New Features
🍪 Comprehensive Cookie Management
A complete cookie management system is now available:
setCookie(),getCookie(), andclearCookie()methods on the response object- New
enableCookieParser()middleware to parse incoming cookies intoreq.cookies - Signed cookies for security with HMAC-SHA256 via
createSignedCookies() - Full support for cookie options (httpOnly, secure, sameSite, etc.)
// Enable cookie parsing
app.enableCookieParser();
// Set a cookie
app.get('/login', (req, res) => {
res.setCookie('session', 'abc123', {
maxAge: 3600,
httpOnly: true,
secure: true
});
res.redirect('/dashboard');
});
// Use signed cookies for added security
const signedCookies = app.createSignedCookies('strong-secret-key');
app.get('/secure', async (req, res) => {
const userId = await signedCookies.getCookie(req, 'userId');
if (!userId) return res.redirect('/login');
res.json({ message: 'Secure content' });
});🚀 Flexible Routing Enhancements
The router now supports:
- Optional route parameters with
/:param?syntax - Wildcard routes with
/*(single segment) and/**(catch-all) patterns - New helper methods for common routing patterns:
app.any()- register a route for all HTTP methodsapp.wildcard()- match a single path segmentapp.catchAll()- match multiple path segments
// Optional parameters
app.get('/users/:id?', (req, res) => {
// Matches both /users and /users/123
const id = req.params.id || 'all';
res.json({ id });
});
// Wildcard routes (matches a single path segment)
app.wildcard('/files', (req, res) => {
const filename = req.params['*'];
res.json({ file: filename });
});
// Catch-all routes (matches multiple path segments)
app.catchAll('/api', (req, res) => {
const path = req.params['**'];
res.json({ path });
});
// Handle any HTTP method
app.any('/health', (req, res) => {
res.json({ status: 'ok', method: req.method });
});🛠️ Enhanced HTTP Methods
Added body parsing to all HTTP methods that commonly use request bodies:
- PUT, PATCH, and DELETE methods now automatically parse request bodies, just like POST
- Access request data directly via
req.bodyin all methods - Optional
customMaxRequestSizeparameter for all body-parsing methods
app.put('/users/:id', async (req, res) => {
const userData = req.body; // Body automatically parsed
// Update user...
res.json({ updated: true });
});
app.delete('/items', async (req, res) => {
const itemIds = req.body.ids; // Access parsed JSON data
// Delete items...
res.status(200).end();
}, 5); // 5MB max request size📝 Template Engine Improvements
- Support for backtick string literals (``) in templates, aligning with modern JavaScript
- Enhanced
dateFormatfilter with improved robustness and formatting options - Better handling of template literals in HTML attributes with ternary operators
<!-- Now you can use backticks in templates -->
<option value="draft" {{ item.status="draft" ? `selected` : `` }}>Draft</option>
<!-- Enhanced date formatting -->
<span>{{ date | dateFormat('YYYY-MM-DD HH:mm') }}</span>Installation & Upgrade
npm install litenode@latestAs always, this release maintains full backward compatibility, so upgrading should be seamless. Check out the documentation for detailed usage instructions.
I appreciate your feedback and contributions - enjoy the new features!
v4.3.0
LiteNode 4.3.0
I'm excited to announce LiteNode 4.3.0, bringing significant enhancements to template handling, static asset management, and configuration capabilities. This release focuses on improved flexibility, performance, and developer experience.
Major Features
Enhanced Template Engine Path Resolution
- Universal directory structure support with unlimited nesting depth
- Flexible include paths that work at any directory level:
- Support for root level files (index.html)
- Single directory files (theme/index.html)
- Deeply nested files (site/theme/templates/index.html)
- Intelligent path resolution that adapts to file location context
- Backward compatible with absolute paths while adding relative path support (./file.html, ../folder/file.html)
- Works seamlessly in both standard (views directory) and root mode
Improved Array Filter System
- New unified property access system for consistent object traversal
- Enhanced error reporting with filter-specific context
- New sortByDate filter for chronological sorting
- Improved handling of nested properties in sortBy, groupBy, and where filters
- Consistent behavior across all array-handling operations
Optimized Static Asset Loading
- Intelligent caching system with environment awareness
- ETag support for validation caching
- Content-type caching to reduce MIME type lookups
- Smart Cache-Control headers based on environment
- Improved file watching with deletion handling
- Cross-platform path normalization
- Enhanced error logging and recovery
Built-in Environment Variable Support
- Native .env file support without external dependencies
- Automatic type conversion for environment variables
- Support for default values and fallbacks
- Configuration for environment-specific settings
- Full TypeScript definition updates
Breaking Changes
None. This release maintains full backward compatibility.
Upgrading
npm install [email protected]Documentation
Full documentation for these new features is available at https://litenode.pages.dev/docs/
v4.2.0
Feature Enhancements:
- Add support for custom template directory configuration
- Allow specifying separate directories for static files and views
- Maintain backward compatibility with default "views" directory
- Update TypeScript definitions to support new constructor parameters
- Pass custom views directory through the template rendering chain
Example Usage:
// Default directories
const app = new LiteNode() // uses ("static", "views")
// Only static directory specified
const app2 = new LiteNode("public") // uses ("public", "views")
// Both directories specified
const app3 = new LiteNode("public", "templates") // uses ("public", "templates")
// Default static, custom views
const app4 = new LiteNode("static", "pages") // uses ("static", "pages")v4.1.0
Add conditional support inside each blocks
- Modify parseEachBody method in StatementParser to handle conditional tags
- Enable if/else, elseif, and not conditions within each loops
- Maintain nested conditional support inside iterations
- Preserve existing each block functionality
v4.0.0
LiteNode 4.0.0: New AST-based Template Engine
Major Changes:
- Complete rewrite of Simple Template Engine (STE) using AST parsing
- Unified template tag signature for simpler syntax
- Extended filter system with 30+ built-in filters
- Enhanced template processing performance
New Features:
- Advanced filter chaining support
- Expanded set of supported static file types
- Browser-renderable and downloadable file categorization
- Improved media file handling (.mp3, .mp4, .webm, .ogg)
Breaking Changes:
- Template syntax has been unified and simplified
- Previous template helpers have been replaced with filters
- Some template tags may require updates to match new syntax
Documentation:
- New comprehensive filter documentation
- Updated template rendering guides
- Expanded static file support documentation
- Migration guide from 3.x to 4.0.0
This release focuses on improving the templating experience
while maintaining LiteNode's core philosophy of simplicity
and efficiency.
v3.5.0
This release addresses key issues and adds new functionality to enhance the user experience.
New Feature
- Add ZIP Content Type Mapping:
- Introduced support for ZIP files by adding ".zip": "application/zip" to the
getContentTypefunction. - Ensures ZIP files are served with the correct Content-Type header.
- Introduced support for ZIP files by adding ".zip": "application/zip" to the
Bug Fixes
- Import readFileSync for sendFile Functionality:
- Fixed a critical issue where
readFileSyncwas not imported, causing runtime errors in thesendFilemethod.
- Fixed a critical issue where
Details
The sendFile method works now as expected and supports sending ZIP archive to the browser as the response.
Thank you for your continued support!
v3.4.0
New Features
- Dynamic Static File Serving and Directory Watching: Introduced dynamic serving of static files and automatic detection of changes in the static directory.
- Integrated Multipart/Form-Data Parsing: Added support for multipart/form-data using the
meroslibrary and renamedjsonHandlertobodyParser. - Support for Custom Maximum Request Size in
postMethod: Enhancedpostmethod to allow custom maximum request size. - Support for
{{@index}}in#eachDirective: Enabled use of{{@index}}placeholder within#eachblocks in the Simple Template Engine.
Details
- Dynamic Static File Serving: Now static files can be served dynamically without server restarts. The static directory is monitored for changes, ensuring that new files are immediately available.
- Multipart/Form-Data Parsing: The
meroslibrary is integrated to handle multipart/form-data, supporting file uploads and form fields. ThejsonHandlerfunction has been renamed tobodyParserfor clarity. - Custom Maximum Request Size: The
postmethod now supports an optional parameter for specifying a custom maximum request size, enhancing control over request handling. - Template Engine Enhancement: The
processEachfunction in the Simple Template Engine now supports the{{@index}}placeholder, allowing access to the current iteration index.
Changes
- Static File Handling: Implemented dynamic route registration, directory watching, improved path handling, and enhanced logging for static files.
- Multipart/Form-Data: Integrated
meroslibrary, updatedbodyParserfunction, improved error handling, and refactored code. postMethod: AddedcustomMaxRequestSizeparameter, updated TypeScript definition, and revised documentation.- Template Engine: Updated
processEachfunction to handle{{@index}}in nested#eachblocks and non-object items.
In-Depth Improvements
-
Static File Handling
- Dynamic Route Registration: Implemented a mechanism to dynamically register routes for static files, enabling the server to handle new files added to the static directory on-the-fly.
- Directory Watching: Added functionality to watch the static directory recursively for any changes (additions), ensuring new files are detected and served without restarting the server.
- Path Handling Refinement: Improved path handling to ensure that route paths are correctly constructed and include the static directory, regardless of the operating system (Windows, macOS, Linux).
- Enhanced Logging: Added detailed logging to trace the addition of new files, route registrations, and file serving, aiding in debugging and ensuring transparency of the process.
- startServer Method Update: Updated the
startServermethod to initialize theStaticAssetLoaderand serve static assets upon server start, integrating the new dynamic file serving feature seamlessly into the server lifecycle.
These changes ensure a more robust and flexible handling of static assets, improving the development and deployment workflow by removing the need for server restarts when static files are modified or added. The static directory is now monitored for changes, and newly added files are automatically registered and served. This ensures that any changes to the static assets are immediately reflected and accessible.
-
Multipart/Form-Data
- Integration with
meros: Added support for parsing multipart/form-data using themeroslibrary, which supports streaming and handles multiple parts efficiently. - Enhanced Request Handling: Updated the
bodyParserfunction to support multipart/form-data, in addition to JSON and URL-encoded form data. - Data Structure: Form fields and file uploads are now stored in the
req.bodyobject, with files accessible as arrays for each field name. - Improved Error Handling: Added logic to handle request size limits and unsupported media types more effectively.
- Refactored Code: Cleaned up and optimized the body parsing logic for better maintainability and performance.
- Function Renaming: Renamed
jsonHandlertobodyParserfor better clarity and consistency.
This new feature makes it easier to handle file uploads and complex form data in your LiteNode applications, enhancing the overall flexibility and functionality of the framework. The renaming of
jsonHandlertobodyParserclarifies the purpose of the function, making the codebase more intuitive. This enhancement allows for efficient parsing of file uploads and form fields, providing a more robust and flexible solution for handling multipart requests. - Integration with
-
postMethod- Enhanced
postMethod: Thepostmethod now accepts an optionalcustomMaxRequestSizeparameter as the last argument in the handler list. This parameter defines the maximum request size in megabytes. - Handler Adjustment: Modified internal handling to use the provided
customMaxRequestSizewhen present, or default to 1MB. - TypeScript Definition Update: The TypeScript definition (
litenode.d.ts) for thepostmethod has been updated to reflect the new parameter. It now allows for an array of route handlers and an optional number specifying the maximum request size. - Documentation Update: Updated examples in the documentation to demonstrate how to use the new
customMaxRequestSizeparameter.
This update enhances the flexibility and control over POST request handling, making it easier to manage and validate large payloads.
- Enhanced
-
Template Engine
- Enhancement: Updated the
processEachfunction to recognize and replace{{@index}}with the current iteration index. - Recursive Processing: Ensured that nested
#eachblocks correctly process the{{@index}}placeholder. - Non-Object Handling: Added support for
{{@index}}in non-object items by replacing the placeholder in the iteration content.
This new feature provides additional flexibility and control when working with arrays in templates, making it easier to create more dynamic and informative content by enhancing the
processEachfunction in the Simple Template Engine to support the{{@index}}placeholder within#eachblocks. The{{@index}}placeholder allows you to access the current index of the iteration, enabling more dynamic and flexible templates. - Enhancement: Updated the
This release significantly enhances flexibility and functionality across multiple aspects of the framework, from static file serving to request handling and template processing.