hex-functions
✖️Function abstraction framework for better portability between platforms. Write your code once in functional approach, then run on mainstream environments such as cli, bot platforms, cloud-function runtimes and web apis.
This project is in early stages of its development. Descriptions or instructions are not mature yet as well as the project itself.
Roadmap
MVP
-
Basic functions -
Input and context interfaces -
Middlewares -
CLI platform -
Runtime -
Web platform w/ oak - Hypertext format
- Web platform w/ Deno's http
- Telegram bot platform
Next Milestones
- API Maturity
- AWS Lambda platform
- Knative platform
- Discord bot platform
- Slack bot platform
- Unit and integration testing utilities
- Dockerization
- Manifest files
- Kafka/queue events
- Scheduled events
- Deployments (to cloud providers)
See eser.dev for further development details (in Turkish).
Usage
Basic
import { results, createRuntime, cli } from "https://deno.land/x/hex/mod.ts";
function main(input) {
const to = input.parameters[0] ?? "world";
const message = `hello ${to}`;
return results.text(message);
}
// will be removed in future versions
// propably will be replaced w/ export
const runtime = createRuntime(cli);
runtime.execute(main);
With Middlewares
import { composer, results, createRuntime, cli } from "https://deno.land/x/hex/mod.ts";
function initMiddleware(input, context, next) {
context.vars.number = 1;
return next();
}
function validationMiddleware(input, context, next) {
if (input.parameters[0] === undefined) {
return results.error(
"parameter is not specified",
new Error("parameter is not specified"),
);
}
return next();
}
function main(input, context) {
const message = `hello ${context.vars.number} ${input.parameters[0]}`;
return results.text(message);
}
const composed = composer(initMiddleware, validationMiddleware, main);
// will be removed in future versions
// propably will be replaced w/ export
const runtime = createRuntime(cli);
runtime.execute(composed);
Quick start
Ensure that Deno
is installed on your system first.
Clone this git repo git clone https://github.com/eserozvataf/hex-functions.git
- and checkout the tagged
release you'd like to
use.
Then run a sample file under samples/
directory,
$ deno run samples/cli/basic.ts eser
hello eser
Todo List
See GitHub Projects for more.
Requirements
- Deno (https://deno.land/)
License
Apache 2.0, for further details, please see LICENSE file.
Contributing
See CONTRIBUTING.md for details.
It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome.
- To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
- To report a bug: If something does not work, please report it using GitHub Issues.