Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ratel-rust/ratel-server
HTTP server for featuring Ratel, the high performance JavaScript to JavaScript compiler
https://github.com/ratel-rust/ratel-server
Last synced: 15 days ago
JSON representation
HTTP server for featuring Ratel, the high performance JavaScript to JavaScript compiler
- Host: GitHub
- URL: https://github.com/ratel-rust/ratel-server
- Owner: ratel-rust
- License: mit
- Created: 2016-10-20T06:46:07.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-21T19:30:57.000Z (almost 8 years ago)
- Last Synced: 2023-03-27T12:08:00.075Z (almost 2 years ago)
- Language: Rust
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
![Ratel](http://maciej.codes/things/ratel-400.png)
# 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
````bash
$ ./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](https://github.com/maciejhirsz/json-rust).
The server responds to any request with a JSON body, f.e.:
````bash
$ 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:
````json
{
"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](https://www.behance.net/alpalmer60b4).
## License
[LICENSE-MIT](LICENSE-MIT)