Nixaweb is a high-performance, modern, and extensible web framework built on top of Fastify. It provides a robust foundation for building scalable and secure web applications with ease. Nixaweb comes packed with a variety of built-in middlewares and features, streamlining the development process and allowing you to focus on building your application's core logic.
- Blazing Fast: Built on Fastify, one of the fastest Node.js web frameworks available.
- Secure by Default: Includes middlewares like
@fastify/helmetand@fastify/rate-limitto enhance security. - Highly Extensible: Easily add custom middleware and plugins to tailor the framework to your needs.
- Built-in Template Engine: Uses EJS for server-side rendering, with built-in HTML minification and JavaScript obfuscation.
- CORS Support: Configurable Cross-Origin Resource Sharing (CORS) via
@fastify/cors. - Form Handling: Seamlessly process form data with
@fastify/formbody. - Compression: Out-of-the-box response compression using
@fastify/compress. - Static File Serving: Serve static assets efficiently with
@fastify/static. - Developer Friendly: Clean and intuitive API with helpful console logging powered by
colors. - Instant Page Loads: Mimics Next.js-style instant page loads by intelligently preloading links within the viewport, resulting in a seamless and snappy user experience.
Nixaweb comes pre-configured with the following essential middlewares:
@fastify/compress: Compresses responses with various encoding algorithms (gzip, deflate, brotli) to reduce bandwidth usage and improve performance.@fastify/cors: Enables Cross-Origin Resource Sharing, allowing requests from different origins.@fastify/express: Provides compatibility with Express middleware, enabling a smoother transition for existing projects. (Consider migrating to native Fastify plugins for optimal performance.)@fastify/formbody: Parses form data submitted throughPOST,PUT, andPATCHrequests.@fastify/helmet: Sets various HTTP headers to secure your application from common web vulnerabilities.@fastify/rate-limit: Protects your application from brute-force attacks and abuse by limiting the rate of incoming requests.@fastify/sensible: Adds helpful utilities and error handling capabilities to enhance the development experience.@fastify/static: Serves static files (e.g., images, CSS, JavaScript) directly from a specified directory.
-
Installation:
git clone https://github.com/Netreon/nixaweb cd nixaweb npm install -
Create Your CSS with PostCSS (using Tailwind CSS): Update the
tailwind.config.cjsfile in the root with your desired configuration. Then, add your styles tosrc/global.css. Run the following command to build your CSS:npm run build
-
Run the Application:
- Development Mode:
npm run dev(usesnodemonfor automatic reloading) - Production Mode:
npm start
- Development Mode:
-
Access the Application: Open your browser and navigate to
http://localhost:3000(or the port configured innixaweb.config.js).
The nixaweb.config.js file allows you to customize various aspects of the framework, including:
port: The port on which the server will listen.security.cors: CORS options.security.rateLimit: Rate limiting settings.security.helmet: Helmet middleware options.speed.compression: Compression options.
- Adding Routes: Create new
.ejsfiles in thesrc/viewsdirectory. The framework automatically creates routes based on the filenames. You can also add more complex routing logic insrc/routes.js. - Adding Middleware: Extend the
middlewares.jsfile to include additional Fastify plugins or custom middleware functions. - Template Engine: Modify the
layout.ejsfile insrc/viewsto change the overall layout of your application. Customize individual pages by creating new.ejsfiles in the same directory.
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.