0.0.13 • Published 10 months ago

@tscircuit/file-server v0.0.13

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

@tscircuit/file-server

A simple file server with REST API and event bus capabilities for managing text files.

Installation

npm install @tscircuit/file-server
# or
bun add @tscircuit/file-server

Command Line Usage

Start the server:

# Start with default port 3062
file-server

# Start with custom port
PORT=8080 file-server

Library Usage

import winterspecBundle from "@tscircuit/file-server"
import { startServer } from "winterspec/adapters/node"

const server = await startServer(winterspecBundle, {
  port: 3062,
})

API Documentation

File Operations

Create/Update File

POST /files/upsert
Content-Type: application/json

{
  "file_id": "optional-id",
  "file_path": "path/to/file.txt",
  "text_content": "File contents here"
}

Response: {
  "file": {
    "file_id": "1",
    "file_path": "path/to/file.txt",
    "text_content": "File contents here",
    "created_at": "2024-01-01T00:00:00.000Z"
  }
}

Get File

GET /files/get?file_id=1
# or
GET /files/get?file_path=path/to/file.txt

Response: {
  "file": {
    "file_id": "1",
    "file_path": "path/to/file.txt",
    "text_content": "File contents here",
    "created_at": "2024-01-01T00:00:00.000Z"
  }
}

List Files

GET /files/list

Response: {
  "file_list": [
    {
      "file_id": "1",
      "file_path": "path/to/file.txt"
    }
  ]
}

Event Operations

Create Event

POST /events/create
Content-Type: application/json

{
  "event_type": "FILE_UPDATED",
  "file_path": "path/to/file.txt"
}

Response: {
  "event": {
    "event_id": "2",
    "event_type": "FILE_UPDATED",
    "file_path": "path/to/file.txt",
    "created_at": "2024-01-01T00:00:00.000Z"
  }
}

List Events

GET /events/list
# or
GET /events/list?since=2024-01-01T00:00:00.000Z

Response: {
  "event_list": [
    {
      "event_id": "2",
      "event_type": "FILE_UPDATED",
      "file_path": "path/to/file.txt",
      "created_at": "2024-01-01T00:00:00.000Z"
    }
  ]
}

Admin Interface

The server includes a web-based admin interface for managing files:

  • /admin/files/list - View all files
  • /admin/files/create - Create new files
  • /admin/files/get?file_path=... - View file details

Event Types

Built-in event types:

  • FILE_UPDATED - Triggered when a file is created or updated

You can create custom event types by using the /events/create endpoint with your own event type names.

Development

# Start development server
bun run dev

# Run tests
bun test

# Build for production
bun run build
0.0.13

10 months ago

0.0.10

10 months ago

0.0.11

10 months ago

0.0.12

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago