Skip to content

Releases: LebCit/litenode

v3.5.0

05 Aug 00:12
Compare
Choose a tag to compare

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 getContentType function.
    • Ensures ZIP files are served with the correct Content-Type header.

Bug Fixes

  • Import readFileSync for sendFile Functionality:
    • Fixed a critical issue where readFileSync was not imported, causing runtime errors in the sendFile method.

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

28 Jul 22:24
Compare
Choose a tag to compare

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 meros library and renamed jsonHandler to bodyParser.
  • Support for Custom Maximum Request Size in post Method: Enhanced post method to allow custom maximum request size.
  • Support for {{@index}} in #each Directive: Enabled use of {{@index}} placeholder within #each blocks 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 meros library is integrated to handle multipart/form-data, supporting file uploads and form fields. The jsonHandler function has been renamed to bodyParser for clarity.
  • Custom Maximum Request Size: The post method now supports an optional parameter for specifying a custom maximum request size, enhancing control over request handling.
  • Template Engine Enhancement: The processEach function 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 meros library, updated bodyParser function, improved error handling, and refactored code.
  • post Method: Added customMaxRequestSize parameter, updated TypeScript definition, and revised documentation.
  • Template Engine: Updated processEach function to handle {{@index}} in nested #each blocks and non-object items.

In-Depth Improvements

  1. 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 startServer method to initialize the StaticAssetLoader and 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.

  2. Multipart/Form-Data

    • Integration with meros: Added support for parsing multipart/form-data using the meros library, which supports streaming and handles multiple parts efficiently.
    • Enhanced Request Handling: Updated the bodyParser function 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.body object, 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 jsonHandler to bodyParser for 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 jsonHandler to bodyParser clarifies 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.

  3. post Method

    • Enhanced post Method: The post method now accepts an optional customMaxRequestSize parameter 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 customMaxRequestSize when present, or default to 1MB.
    • TypeScript Definition Update: The TypeScript definition (litenode.d.ts) for the post method 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 customMaxRequestSize parameter.

    This update enhances the flexibility and control over POST request handling, making it easier to manage and validate large payloads.

  4. Template Engine

    • Enhancement: Updated the processEach function to recognize and replace {{@index}} with the current iteration index.
    • Recursive Processing: Ensured that nested #each blocks 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 processEach function in the Simple Template Engine to support the {{@index}} placeholder within #each blocks. The {{@index}} placeholder allows you to access the current index of the iteration, enabling more dynamic and flexible templates.

This release significantly enhances flexibility and functionality across multiple aspects of the framework, from static file serving to request handling and template processing.

v3.3.1

20 Jul 06:37
Compare
Choose a tag to compare

Fix

Enhanced Condition Evaluation

Details

This patch enhances the condition evaluation functionality to support all logical and comparison operators, ensuring robust and comprehensive condition handling in templates.

Changes

  1. Enhance condition evaluation to support all logical and comparison operators
    • Updated evaluateCondition to handle logical operators (&&, ||) and comparison operators (==, !=, >=, <=, <, >).
    • Ensured evaluateSimpleExpression correctly evaluates both logical and comparison expressions.

v3.3.0

19 Jul 20:52
Compare
Choose a tag to compare

New Features

  • Enhanced resolveValue to support nested properties with dot notation.
  • Updated evaluateCondition to handle logical operators and simple conditions.
  • Refactored evaluateSimpleExpression and evaluateComparison for accurate condition evaluations.
  • Added fileBaseName property to parseFrontmatter return object.

Details

This release introduces several improvements and new features to enhance the functionality and flexibility of the template engine and frontmatter parsing.

Changes

  1. Enhance resolveValue to support nested properties with dot notation

    • Updated the resolveValue function to handle nested keys using dot notation.
    • Ensured proper value resolution from data objects for nested properties.
  2. Update evaluateCondition to handle logical operators and simple conditions

    • Modified evaluateCondition to distinguish between logical expressions and simple truthy checks.
    • Integrated resolveValue for simple condition evaluations.
  3. Refactor evaluateSimpleExpression and evaluateComparison for accurate condition evaluations

    • Enhanced evaluateSimpleExpression to evaluate conditions with logical operators.
    • Updated evaluateComparison to perform comparisons using resolved values.
    • Ensured consistent and correct evaluation of expressions.
  4. Add fileBaseName property to parseFrontmatter return object

    • Added fileBaseName to the returned object from the parseFrontmatter function.
    • This property contains the base name of the file without its extension.

This release brings significant enhancements to the way nested properties and logical conditions expressions are evaluated in the template engine (see docs), as well as improvements to the frontmatter parsing functionality. As always, your feedback and contributions are most welcome. Thank you for using LiteNode!

v3.2.0

17 Jul 21:35
Compare
Choose a tag to compare

New Feature

Enhanced Body Parsing Support

Details

I'm excited to announce the release of version 3.2.0 of LiteNode, which includes a significant enhancement to the request body parsing capabilities. This update adds support for parsing application/x-www-form-urlencoded content types in addition to the existing application/json support. This improvement allows for greater flexibility and ease of handling different types of data in POST requests.

Changes

  • Integrated Body Parser:

    • The jsonHandler function has been enhanced to support application/x-www-form-urlencoded content types, making it easier to handle form data.
    • The framework now correctly parses URL-encoded form data and assigns nested properties within the parsed object.
  • Updated Documentation:

    • The description for the integrated body parser has been updated to reflect the new functionality, supporting both application/json and application/x-www-form-urlencoded content types.
    • Documentation links have been updated accordingly to guide users on how to utilize the enhanced body parser.
  • Reminder - Automated Version Check:

    • Since the previous version, LiteNode automatically checks for and notifies you if a new version is available whenever the server starts, ensuring you stay up-to-date with the latest features and improvements.

I hope these enhancements improve your experience with LiteNode and make it even easier to build robust and flexible web applications. As always, your feedback and contributions are most welcome. Thank you for using LiteNode!

v3.1.0

13 Jul 23:40
Compare
Choose a tag to compare

New Features

  • Add method for sending HTML responses
  • Add method for sending XML responses
  • Add a check for LiteNode's update on server start

Details

While STE can effectively render HTML templates, it is a Simple Template Engine suitable for straightforward HTML architectures where the transferred data doesn't need complex manipulation. Therefore, LiteNode provides an html method extending the response object, enabling users to employ another template engine with LiteNode.

The xml method is particularly useful for API endpoints or responses where XML is the desired format, such as RSS feeds and sitemaps.

"The startServer method now includes an update verification feature."

Changes

  • feat: add update check with internet connectivity verification to startServer method
  • feat: enhance startServer method to await update check and return server instance
  • feat(response): add method for sending HTML responses
  • feat(response): add method for sending XML responses
  • feat(types): add TypeScript definition for html method
  • feat(types): add TypeScript definition for xml method
  • refactor: Improve clarity and efficiency of frontmatter validation
  • refactor(STE): enhance template rendering with replacePlaceholders method
  • refactor(processEach): improve placeholder resolution and recursive processing
  • docs(paginator): add JSDoc comments and enhance pagination logic
  • chore(release): bump version to 3.1.0

v3.0.0

05 Jul 21:32
Compare
Choose a tag to compare

Details

In LiteNode v3.0.0, I've undertaken a complete ground-up rewrite to enhance modularity and maintainability. This major update reorganizes the core structure by breaking down functionalities into individual modules, allowing for cleaner code and easier management. By separating internal methods and classes into dedicated files, I've significantly improved code readability and extensibility, paving the way for future enhancements and smoother integrations. This release marks a pivotal step in LiteNode's evolution, offering a more robust and scalable framework for your projects.

BREAKING CHANGE: As of version 3.0.0, LiteNode no longer supports being loaded using require. This change aims to maintain and enhance LiteNode in a modular way, which would be difficult to achieve if backward compatibility with CommonJS were maintained.

Changes

  • Put LiteNode's declaration in a "types" directory
  • Create utility functions in "utils" folder within "core" directory
  • Refactor preprocessConditionals: split into multiple files
  • Refactor: Separate readFileContent and handleIncludes into individual files
  • Refactor: Modularize STE class by importing functions from separate files
  • Refactor: Break down SMP class functions into separate files
  • Refactor: Modularize SMP class by importing functions from separate files
  • Refactor: Separate Markdown helper functions into individual files
  • Refactor: Separate LiteNode's private methods into individual files
  • Refactor: Separate RouteNode and StaticAssetLoader classes into individual files
  • Refactor: Modularize LiteNode class by importing functions from separate files
  • Docs: Update README with breaking change note and remove incompatible code
  • Chore: Bump version to 3.0.0 and update package.json configuration

v2.1.1

02 Jul 21:55
Compare
Choose a tag to compare

Changes

v2.1.0

26 Jun 13:51
Compare
Choose a tag to compare

New Feature

Add support for nested each blocks and dot notation.

Details

The {{#each}} directive can now access the object's properties using dot notation. Nested loops can be handled by incrementing the each number.

Changes

  • Enhanced each loop functionality to handle nested eachN blocks automatically.
  • Implemented support for dot notation to access nested object properties within each loops.
  • Updated documentation to reflect new features and usage examples.
  • Bumped version from 2.0.0 to 2.1.0.

v2.0.0

19 Jun 11:53
Compare
Choose a tag to compare

New Features

  • Added full JSDoc in litenode.d.ts for each and every method
  • Rendering templates is now asynchronous
  • addIdsToHeadings has been integrated into SMP (Simple Markdown Parser)
  • extractMarkdownProperties is now asynchronous and supports an array, a folder or a file as an input
  • Added new methods: groupByMarkdownProperty, paginateMarkdownFiles and generateTOC

Details

A detailed documentation of these new capabilities, is available in the new version of LiteNode's documentation.

  • If you use an IDE that supports autocomplete, you'll see a brief description and example when using LiteNode's methods as well as a link to the method's documentation.
  • Rendering templates has been updated to be asynchronous.
  • IDs for heading tags in Markdown, addIdsToHeadings, has been fully integrated into SMP. Now you can just write {# my-id} and LiteNode will take care of it for you!
  • Properties can now be extracted from a single file, from multiple files in the same directory or from an array of files.
  • groupByMarkdownProperty helps in categorizing or organizing markdown files based on a specific frontmatter field.
  • paginateMarkdownFiles helps in displaying markdown files in a paginated format, useful for creating blogs or documentations.
  • generateTOC helps in creating a TOC for better navigation within documents.

Changes

  • Add JSDoc for all methods
  • Make rendering asynchronous
  • Ingrate addIdsToHeadings into SMP. Ensure Markdown heading tags in code's blocks are not parsed to HTML.
  • Make extractMarkdownProperties async. Input can be array, folder or file.
  • Add groupByMarkdownProperty method.
  • Add paginateMarkdownFiles method.
  • Add generateTOC method.
  • Bump LiteNode to major version and publish.