Skip to content

HTTP server for featuring Ratel, the high performance JavaScript to JavaScript compiler

License

Notifications You must be signed in to change notification settings

ratel-rust/ratel-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ratel

ratel-server

Ratel is a high performance JavaScript to JavaScript compiler with a Rust core. It's goal is to take newest versions of JavaScript as input, and produce output that's compatible with older versions of the language.

This is a very simple HTTP server that will accept ES2015+ JavaScript and responds with ES5 compiled code.

Building

Have Rust installed, then execute cargo build --release in the root directory of this repository.

Usage and environment variables

  $ ./target/release/ratel-server

The following environment variables can be used:

name default value description
HOST 0.0.0.0 binding IPv4 address
PORT 3000 port number
CORS false Whether to include a CORS header

API

ratel-server implements a JSON API using json-rust.

The server responds to any request with a JSON body, f.e.:

 $ curl 'http://0.0.0.0:3000' \
   -H 'content-type: application/json' \
   -d '{"source":"const foo = 2;\nconst bar = foo**2;","minify":false,"ast":false}'

results in:

{
  "result": "var foo = 2;\nvar bar = Math.pow(foo, 2);\n",
  "success": true
}

The following options are available.

key mandatory type description
source yes String The JavaScript source code to compile
minify no Boolean Whether to minify the output
ast no Boolean Whether to return the AST

Logo

The smirky Ratel by the courtesy of A. L. Palmer.

License

LICENSE-MIT

About

HTTP server for featuring Ratel, the high performance JavaScript to JavaScript compiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages