8000 GitHub - forax/jexpress: A light express.js like library written in Java (in one file)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

forax/jexpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jexpress

JExpress.java, a light and slow express.js clone written in Java 25 (in one file). It uses virtual threads with its own single-thread scheduled (using Unsafe hence the warnings at start-up).

There is also JExpress17.java, a version backward compatible with Java 17 (supports JSON <-> record mapping). 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 Java 25

    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

Contributors 2

  •  
  •  

Languages

0