LiteNode's logo

LiteNode

Docs GitHub logo
▶ Usage

Documentation

About LiteNode

Overview

LiteNode is a lightweight and modular Node.js web framework designed to provide essential web server functionalities with a clean and intuitive API. It leverages modern JavaScript features while ensuring compatibility with both CommonJS and ES6 modules, making it versatile for various development environments. LiteNode is suitable for developers seeking a straightforward yet powerful solution for building web applications.

Key Features

  1. Routing: LiteNode offers a robust routing system that allows defining routes with different HTTP methods (GET, POST, PUT, DELETE, PATCH). It supports parameterized routes and nested routing, providing flexibility in organizing route handlers.

  2. Middleware: The framework supports middleware functions, enabling developers to execute code, make changes to the request and response objects, end the request-response cycle, and call the next middleware in the stack.

  3. Error Handling: LiteNode includes comprehensive error handling capabilities, allowing custom error handlers to be defined. This ensures that errors are managed gracefully and that appropriate responses are sent to the client.

  4. Request Body Parsing: The framework includes built-in support for parsing request bodies, simplifying the handling of POST requests. It supports application/json, application/x-www-form-urlencoded and multipart/form-data content types, ensuring that data is correctly parsed and accessible.

  5. Static Asset Serving: LiteNode can serve static files from a specified directory, making it easy to deliver images, CSS files, JavaScript files, and other assets to clients, without server restart.

  6. Extensibility: LiteNode supports nesting routers (nest method) and merging routes from other routers (merge method). This allows for modularizing route handling and reusing code.

  7. Server Initialization: The framework provides a simple and efficient way to start the server with customizable options such as port configuration.

  8. Utility Methods: LiteNode includes utility methods like printTree, which helps visualize the routing structure, aiding in debugging and understanding the application's routing hierarchy. It also provides several utility methods to simplify response handling and routing management. The txt method allows for easy sending of plain text responses by setting the Content-Type header to text/plain and sending the provided text as the response body. This complements other response methods such as json, status, sendFile, html, xml, and render, making it straightforward to return various types of content to the client.

  9. Parameters (params and queryParams): The framework supports route parameters and query parameters, making it easy to capture dynamic values from URLs and query strings.

  10. Redirect: The redirect method allows for easy redirection of requests to different URLs, with support for specifying HTTP status codes for temporary or permanent redirects.

  11. .json: The json method simplifies sending JSON responses by setting the appropriate headers and stringifying the data.

  12. .status: The status method allows setting HTTP status codes before sending a response, supporting method chaining for cleaner code.

  13. .sendFile: The sendFile method facilitates sending files as responses, setting the appropriate Content-Type headers based on file extensions.

  14. .txt: The txt method enhances the versatility of the response object, allowing developers to easily send plain text responses without manually setting headers and ending the response. This contributes to cleaner and more readable code.

  15. .html: By setting the Content-Type header to text/html and delivering the provided HTML content as the response body, this method ensures that HTML content is correctly handled and returned to the client, enabling users to employ another template engine with LiteNode than its integrated Simple Template Engine.

  16. .xml: The xml method is a useful addition to the response object, simplifying the process of sending XML responses. This method is particularly useful for API endpoints or responses where XML is the desired format, such as RSS feeds and sitemaps.

  17. Templating: LiteNode integrates the STE (Simple Template Engine) for rendering HTML templates. It supports placeholders, dynamic data injection, and includes directives for modular and reusable templates. Additionally, LiteNode provides the ability to render templates to files, making it easy to generate static HTML files for various use cases such as static site generation.

  18. Markdown: LiteNode enhances the parsing and rendering of Markdown files, a feature inherited from Blog-Doc CMS & SSG. It includes methods for parsing individual Markdown files, parsing multiple Markdown files from a directory, and extracting specific properties from the frontmatter. This makes LiteNode a powerful and flexible tool for managing content-rich applications, offering robust capabilities for handling Markdown files efficiently.

Strengths

Use Cases

Conclusion

LiteNode is a versatile and efficient web framework for Node.js, offering a range of features that cater to modern web development needs. Its lightweight design, coupled with powerful routing, middleware, and templating capabilities, makes it an excellent choice for developers seeking a balance between simplicity and functionality. Whether building small web applications, APIs, or static websites, LiteNode provides a solid foundation for rapid development and deployment.

Origins

LiteNode is built on the foundation of Velocy.
LiteNode extends and improves upon Velocy's features to provide a seamless development experience for building web applications. You can read more about it in LiteNode, Node.js Web Framework.

License

LiteNode is licensed under the MIT License. See the LICENSE file for details.

Issues

If you encounter any issues or have suggestions for improvement, please report them on the GitHub Issues page.

Contributing

Contributions are welcome! Feel free to fork the repository and submit pull requests with your enhancements.

Author

LiteNode is authored by LebCit.

Content