fractal-lang
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

fractal-lang

Fractal Lang is an extension of TypeScript for the cloud.

Install

npm install --save-dev fractal-lang

Projen Template

npx projen new --from projen-fractal

Your first Function

The lambda construct from fractal-lang is used to create a serverless Function.

import { lambda } from "fractal-lang";

const HelloFunction = lambda((name: string) => {
  console.log(`hello ${name}`);
});

The HelloFunction expects a JSON payload that matches the function signature.

{
  "name": "Sam"
}

If you call the function with an invalid payload, an error is thrown. This type-safety is inferred directly by parsing the TypeScript code and enforced by the Fractal Cloud Platform.

Store and Retrieve Data

Databases can be created and used as simple as an in-memory data structure.

import { lambda, Table, shapeOf } from "fractal-lang";

interface Person {
  name: string;
}

const People = new Table({
  item: shapeOf<Person>(),
  key: "name",
});

The People Table configures a serverless key-value database for storing Person objects. It can be simply referenced from within a lambda closure to implement backend capabilities such as getting an item.

const GetPersonFunction = lambda((name: string) => People.get(name));

In an ordinary IaC framework, developers would be required to write boilerplate to configure permissions, environment variables and instantiate client libraries, all just to interact with the Table.

In Fractal, all of this is inferred from your TypeScript code directly.

Readme

Keywords

none

Package Sidebar

Install

npm i fractal-lang

Weekly Downloads

1

Version

0.3.5

License

Apache-2.0

Unpacked Size

239 kB

Total Files

155

Last publish

Collaborators

  • sam-goodwin