https://github.com/alash3al/aggrex
a crazy API gateway aggregation using javascript as a language and go as a runtime
https://github.com/alash3al/aggrex
aggregator api api-client api-gateway cloud golang javascript mapreduce reverse-proxy
Last synced: about 1 year ago
JSON representation
a crazy API gateway aggregation using javascript as a language and go as a runtime
- Host: GitHub
- URL: https://github.com/alash3al/aggrex
- Owner: alash3al
- License: mit
- Created: 2018-04-17T12:10:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-14T07:54:40.000Z (almost 8 years ago)
- Last Synced: 2025-03-30T10:33:39.716Z (about 1 year ago)
- Topics: aggregator, api, api-client, api-gateway, cloud, golang, javascript, mapreduce, reverse-proxy
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 16
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
AggreX
=======
> Just a scriptable APIs aggregator using the simple `javascript` syntax
```bash
curl -d "\
var continent = fetch({url: 'http://country.io/continent.json'}); \
var names = fetch({url: 'http://country.io/names.json'}); \
var exports = {
c: continent.body,
n: names.body
};\
" localhost:6030
```
Features
========
- Using a simple `javascript` interpreter to execute your requests
- Using the [`underscore.js`](http://underscorejs.org) library for helper functions
- Stored procedures`!`
- Procedures search engine`!`
- Lightweight & High concurrent request dispatcher
- Built using `Golang`
Why
====
> I wanted a genaric way to call multiple endpoints from the browser without the ajax hell so I won't reduce the page load performance, as well as I don't want to create a customized script to aggregate the endpoints for me, I need it to be genaric.
Installation
=============
> Just goto the [releases](https://github.com/alash3al/aggrex/releases) page and download yours
Usage
=====
#### CLI Flags
```bash
➜ ~ aggrex -h
Usage of aggrex:
-admin-token string
the admin secret token (default "bbh42d0186vj9c87qdc0")
-allowed-hosts all are allowed
the allowed hosts, empty means all are allowed
-http string
the http listen address (default ":6030")
-index string
the database index (default "/home/alash3al/.aggrex")
-max-body-size int
max body size in MB (default 2)
-max-exec-time int
max execution time of each script in seconds (default 5)
```
#### Run
```bash
➜ ~ aggrex
```
#### Example
```bash
➜ ~ curl -d "exports.example = fetch({url: 'http://country.io/names.json'})" localhost:6030
```
Javascript API
==============
> as well as the basic javascript keywords/objects there are two things `fetch()` and `_` (underscore)
#### # `fetch(options)`
```javascript
var resp = fetch({
url: "http://localhost", // the url
method: "GET", // the http method
headers: { // the request headers
"key": "value"
},
proxy: "", // the proxy to be used
redirects: 5, // the maximum redirects count
body: "" // the request body (anything to be sent i.e 'string', 'object' ... etc)
})
var statusCode = resp.statusCode
var headers = resp.headers
var size = resp.size
var body = resp.body
// you must fill the exports variable, because this is the main var used as a response
exports.example = body
```
### # `utils.btoa(string)`
### # `utils.atob(string)`
### # `utils.uniqid(integer length)`
### # `utils.md5(string)`
### # `utils.sha256(string)`
### # `utils.sha512(string)`
### # `utils.bcrypt(string)`
### # `utils.bcryptCheck(string hashed, string real)`
### # `utils.fetch(Object args)`
### # `utils.collect()`, `underscore.js`
### # `requests.headers` `Object`
### # `requests.query` `Object`
### # `requests.body` `Object`
### # `requests.host` `String`
### # `requests.proto` `String`
### # `requests.remote_addr` `String`
### # `requests.uri` `String`
### # `cron.set(string key, string interval, closure job)`
### # `cron.unset(string key)`
### # `cron.list() Object`
### # `globals` `Object`
RESTful API [](https://app.getpostman.com/run-collection/dac8c42fcce004c6c7e8)
=============
> Goto the postman [documenter](https://documenter.getpostman.com/view/2408647/aggrex/RW1aJfJ8)
Contribution
============
Weclome :)
Author
=========
I'm [Mohammed Al Ashaal](http://github.com/alash3al), a Gopher ;)