Skip to content

πŸš€ | Minimal Express built with TypeScript

Notifications You must be signed in to change notification settings

criszst/MyExpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ MyExpress

A lightweight Express-like framework that I built for fun. While I won’t be implementing all the features of Express, I’ll be adding the essential ones to keep the project clean and functional.

βœ… Checklist

  • Basic app with send, post, res, req, and next methods.
  • Recreated some libraries to reduce dependencies (better for security).
  • Interfaces to keep the code clean and maintainable.
  • Function to send an HTML file to the client.
  • More built-in middlewares.
  • Additional tests.

⚑ Features

  • send(data) β†’ Sends an object or text directly to the client.
  • json(data) β†’ Returns a JSON response.
  • download(filePath) β†’ Sends a file to be downloaded by the client.
  • redirect(url) β†’ Redirects the client to a specific URL (public domain or local project file).
  • sendFile(filePath) (in development...) β†’ Sends the content of a file to the client (currently supports only .txt files).

πŸ“Œ Usage

Some quick examples of how to use it:

response.send("Hello, client!"); // Sends a text response  
response.json({ hello: "world" }); // Sends a JSON response  
response.download("./download.test.txt"); // Forces a file download  
response.redirect("https://example.com"); // Redirects the user  
response.sendFile("./index.html"); // (Coming soon!) Sends the content of a file  

Note: The sendFile method is still under development and currently only supports .txt files


πŸ”§ Installation

First, clone the repository:

git clone https://github.com/criszst/MyExpress.git

Navigate into the project directory:

cd MyExpress

Then, install dependencies:

npm install

If you want to run tests (optional but recommended):

npm run test

Since Node.js can't run TypeScript files directly, compile the project:

npm run build

Finally, start the server:

npm run start

🌍 Running the Server

The server runs on port 3000. Once it's up, visit:

http://localhost:3000

You should see the message:
Hello, world!

Releases

No releases published

Packages

No packages published