Sign inSign up

aztekode/golt

By aztekode

•Updated 5 months ago

Go-native TypeScript/JavaScript runtime with HTTP, DB, FS, fetch, crypto and JWT APIs.

Image
Languages & frameworks
Web servers
0

1.6K

aztekode/golt repository overview

⁠Golt Runtime

Golt is a lightweight TypeScript/JavaScript backend runtime written in Go.

It bundles a TypeScript entry file with esbuild and executes it inside a Go-hosted JavaScript engine, exposing a small and explicit backend API surface for HTTP, SQL databases, filesystem access, crypto, JWT, environment variables, logging, and outbound HTTP requests.

⁠Image

docker pull aztekode/golt:latest

Available tags:

aztekode/golt:latest
aztekode/golt:1.0.2

⁠Quick Start

Run a Golt project from your current directory:

docker run --rm \
  -p 3000:3000 \
  -v "$PWD":/workspace \
  -w /workspace \
  aztekode/golt:latest \
  run app.ts

PowerShell:

docker run --rm `
  -p 3000:3000 `
  -v "${PWD}:/workspace" `
  -w /workspace `
  aztekode/golt:latest `
  run app.ts

Then open:

http://localhost:3000

⁠Example app.ts

const app = Golt.App();

app.use(Golt.logger({ format: "dev" }));

app.get("/", (ctx) => {
  ctx.Json({
    ok: true,
    message: "Hello from Golt inside Docker",
  });
});

app.serve(3000);

⁠Use as a base image

Create a Dockerfile in your Golt project:

FROM aztekode/golt:latest

WORKDIR /app

COPY . .

EXPOSE 3000

CMD ["run", "app.ts"]

Build and run your app:

docker build -t my-golt-app .
docker run --rm -p 3000:3000 my-golt-app

⁠Docker Compose

services:
  app:
    image: aztekode/golt:latest
    working_dir: /workspace
    command: ["run", "app.ts"]
    ports:
      - "3000:3000"
    volumes:
      - .:/workspace

Run it with:

docker compose up

⁠Runtime APIs

Golt currently provides:

  • console.log
  • Golt.env
  • Golt.App
  • Golt.logger
  • Golt.db
  • Golt.fs
  • Golt.crypto
  • Golt.jwt
  • global fetch()

⁠Database example

Use db.exec() for statements that do not return rows, and db.query() for statements that return rows.

const db = Golt.db.connect("sqlite", "./app.db");

await db.exec(`
  CREATE TABLE IF NOT EXISTS users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL
  )
`);

await db.exec("INSERT INTO users(name) VALUES (?)", "Ada");

const users = await db.query("SELECT id, name FROM users");

console.log(users);

⁠License

This project currently does not include an open source license file. Until a license is added, all rights are reserved by default.

Tag summary

Content type

Image

Digest

sha256:92e0bedbf…

Size

14 MB

Last updated

5 months ago

docker pull aztekode/golt