This is the backend for the ASCII Art Printer app. It handles file uploads, processes text files line by line, and communicates with the frontend in real-time using WebSocket.
- I want to emphasise that my primary focus for this project is on the frontend development, showcasing my ability to work with real-time payloads, styling, and handling the user experience.
- While I implemented the backend using Node.js, it hasn't been heavily optimized, refactored into TypeScript, or modularized. I approached it as a functional solution to meet the app's requirements.
- I included extensive comments in the backend code for clarity and my own learning.
- File upload handling via Multer middleware.
- Real-time updates using WebSocket (Socket.IO).
- Processes text files line by line, emitting progress and completion events.
- Deletes the uploaded file after processing to save storage.
- Node.js (node version in
.nvmrcfile) - npm (comes with Node.js)
- Clone repository to a folder of your choice.
- Install dependencies: (check .nvmrc for node version)
npm install
- Start backend server
node server.js
- Server will start on:
http://localhost:3000
-
Ensure the backend is running before using the frontend.
-
The backend exposes the following endpoints:
- POST /upload: Handles
.txtfile uploads and processes them.
- POST /upload: Handles
-
The backend communicates with the frontend via WebSocket (Socket.IO):
- Emits
"line": Sends a line from the file along with the progress percentage. - Emits
"complete": Signals the end of file processing.
- Emits
- Node.js: Backend framework.
- Express: For building the REST API.
- Socket.IO: For real-time WebSocket communication.
- Multer: Middleware for handling file uploads.
- fs: Node.js module for file system operations.