Skip to content

TypeScript toolchain for developing cloud-based apps

License

Notifications You must be signed in to change notification settings

JadenSimon/synapse

 
 

Repository files navigation

Synapse

Build Status

Synapse is a toolchain for building and deploying TypeScript applications, from CLI tools to full-stack apps. Your application's infrastructure is defined within the application itself.

Features:

  • Multi-stage programming - run code at build time to create exactly what you need
  • Cloud agnostic libraries - write once, deploy anywhere, including locally
  • Automatic permissions solver - least privilege permissions via symbol execution
  • Native modules - write modules using Zig with automatic TypeScript bindings (coming soon)
  • Everything you need, built-in
    • TypeScript compiler and bundler
    • Incremental builds (distributed caching coming soon)
    • Extremely fast package manager
    • Node.js compatible JavaScript runtime
    • A testing framework
import { Bucket } from 'synapse:srl/storage'

// `Bucket` is a storage resource, which can be deployed locally or to the cloud
const bucket = new Bucket()

export async function main() {
    const data = await bucket.get('hello', 'utf-8')
    console.log('hello', data)

    if (data === undefined) {
        await bucket.put('hello', 'world!')
        console.log('Wrote to the bucket, run me again!')
    }
}

How it works

One way to think about Synapse is to imagine a "metaprogram" that controls what code is executed and where it is executed. Synapse enables you to write code describing this metaprogram within traditional code.

The basic idea is that your code is executed at build time to generate instructions for your metaprogram. An instruction is best thought of as an individual goal state. For example, writing new Bucket() describes an instruction that creates a bucket if it does not already exist. Most instructions exist as configuration for resources. The remaining instructions are purely computational.

A "resource" is essentially anything that can be configured and persisted at build time. The idea of resources is deeply integrated into Synapse, meaning you can find them in many places:

synapse deploy executes (or applies) your metaprogram, creating or updating a deployment. Deployments are the side-effects of instructions and their resulting state. Note that resources are effectively "frozen" outside of synapse deploy. Trying to create/update resources at runtime using Synapse APIs will fail.

Installation

These commands download and execute a script that will:

  • Download a release compatible with your system
  • Extract to ~/.synapse
  • Add synapse to your PATH

macOS/Linux

curl -fsSL https://synap.sh/install | bash

Windows

irm https://synap.sh/install.ps1 | iex

Getting Started

See Quick Start for basic instructions.

For help with specific features:

Attributions

The core functionality of Synapse is built on top of several amazing projects:

And it wouldn't have been possible to create Synapse without them and their contributors!

Each cloud target also uses their respective SDK + Terraform provider. The AWS target uses:

A few things were also inspired by Bun. Most notably is the usage of Zig.

About

TypeScript toolchain for developing cloud-based apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.3%
  • Zig 3.8%
  • Other 0.9%