Skip to content

Latest commit

 

History

History
63 lines (42 loc) · 1.93 KB

README.md

File metadata and controls

63 lines (42 loc) · 1.93 KB

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