Fanoosa.JS is a simple Node.js application that demonstrates basic server setup, routing, error handling, and request processing. This project helps in understanding how to structure a Node.js application, create a server, define routes, handle errors, and work with controllers.
- HTTP Server: A basic HTTP server created using Node.js.
- Routing: A flexible routing system to define and resolve routes based on HTTP methods.
- Error Handling: A centralized error handler to manage different types of errors like 404 (not found), 400 (bad request), and 500 (server error).
- Form Handling: Integration with
formidableto handle form data parsing and validation. - Pagination: Pagination feature to handle large sets of data.
- MVC Architecture: The project follows the MVC (Model-View-Controller) design pattern for better organization and scalability.
Before you begin, ensure you have met the following requirements:
- Node.js (v14 or later)
- npm (Node Package Manager)
- dotenv for environment variable management
-
Clone the repository:
git clone https://github.com/thesiamak01/fanoosa-js.git cd fanoosa-js -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and set the desired configurations (e.g., port):PORT=5000
-
Start the server:
npm run dev
The server will start and be accessible at
http://localhost:5000.
- Server: The application starts an HTTP server listening on the port defined in
.env. - Routes: The routes are defined in the
Routes.jsfile and added to theRouterclass. - Request Handling: Incoming requests are processed by the
RequestHandlerwhich matches the routes and invokes the appropriate controller method. - Error Handling: Errors are caught and handled by the
ErrorHandlerclass which categorizes them and sends appropriate HTTP responses.
If you'd like to contribute to Fanoosa.JS, feel free to fork the repository, make changes, and submit a pull request.