Skip to content
/ jexpress Public

A light express.js like library written in Java (in one file)

License

Notifications You must be signed in to change notification settings

forax/jexpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jexpress

JExpress.java, a light and slow express.js clone written in Java 17 (in one file). It uses virtual threads if run with Java 21 (or Java 19/20 with --enable-preview).

There is also JExpress8.java, a version backward compatible with Java 8.

The full javadoc

Example

public static void main(String[] args) {
  var app = express();
  app.use(staticFiles(Path.of("public")));

  app.get("/hello/:id", (req, res) -> {
    var id = req.param("id");
    record Hello(String id) {}
    res.json(new Hello(id));
  });
  
  app.get("/LICENSE", (req, res) -> {
    res.sendFile(Path.of("LICENSE"));
  });

  app.listen(3000);
}

Run and test

  • Run the application with

    cd src/main/java
    java JExpress.java
    
  • Test the application with Maven

    mvn clean package
    

About

A light express.js like library written in Java (in one file)

Topics

Resources

License

Stars

Watchers

Forks

Languages