Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DimondKudzai/file_reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“‚ File Reader API

A simple Node API that reads a file from the server’s filesystem and returns its contents as a response. Useful for learning how to handle file I/O in Node.js and exposing data through REST endpoints.


πŸ“Œ Features

  • βœ… **Read File * β€” `/api/data' returns the contents of a specified file.
  • βœ… Easy to Extend β€” Add support for multiple files, file uploads, or streaming.

πŸ“‚ Project Structure

file_reader/ β”œβ”€β”€ app.js # Main server file β”œβ”€β”€ data/sample.txt # Example file to read └── README.md # Documentation

`


βš™οΈ Installation

git clone:                                              
cd file_reader
`

▢️ Running the Server
node app.js

You’ll see:
Server running on port 3000

πŸ“– API Usage
GET `/api/data`
Returns the contents of `sample.txt` (or any configured file).

*Example:*
http://localhost:3000/api/data

*Response:*
Hello, this is the content of sample.txt

⚠️ Error Responses
- *404 Not Found* β€” File does not exist.
- *500 Internal Server Error* β€” Could not read file.
πŸ“Œ To-Do (Optional Enhancements)
- [ ] Add support for reading multiple files via `/file/:filename`.
- [ ] Add file upload endpoint.
- [ ] Stream large files instead of loading into memory.
- [ ] Add authentication for sensitive files.
πŸ“„ License
MIT β€” free to use and modify.
πŸ™‹β€β™‚οΈ Author
*Dimond Madechawo*
https://github.com/dimondkudzai

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors