Socket
Book a DemoInstallSign in
Socket

bridge-compile

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bridge-compile

Compile the sdk of your Bridge project with one command locally

1.0.38
latest
Source
npmnpm
Version published
Weekly downloads
2
-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

Bridge Studio

Compile a completely typed sdk of your Bridge project with one command.

Features

  • TypeScript SDK Generation: Generates a TypeScript SDK with typed API methods
  • Swift SDK Generation: Generates a Swift SDK with async/await support and proper error handling
  • OpenAPI Specification: Automatically generates OpenAPI documentation

Usage

Run the compiler in your Bridge project:

npx bridge-compile

This will automatically generate:

  • TypeScript SDK in ./sdk/ directory
  • Swift SDK as ./sdk.swift file
  • OpenAPI documentation as ./openapi.json

You'll only be prompted for your server URL if no configuration file exists.

Configuration

You can create a bridge.config.json file to avoid the server URL prompt:

{
  "serverUrl": "http://localhost:8080"
}

You can also pass the server URL as a command line argument:

npx bridge-compile http://localhost:8080

Swift SDK

The Swift SDK generates a single sdk.swift file that includes:

  • Foundation networking code with async/await support
  • Strongly typed request/response models
  • Error handling with custom APIError type
  • Support for GET, POST, PUT, PATCH, DELETE methods
  • Query parameters, headers, and body support

Swift SDK Structure

// Base networking layer
struct APIError: Error { ... }
struct Result<T: Decodable> { ... }
func fetch<R: Decodable>(...) async -> Result<R> { ... }

// Generated API classes
class User {
    struct CreateBody: Encodable { ... }
    struct CreateResponse: Decodable { ... }

    func create(body: CreateBody) async -> Result<CreateResponse> { ... }
}

// Main API entry point
public class API {
    let user = User()
}

Using the Swift SDK

let api = API()

// Create a user
let result = await api.user.create(body: User.CreateBody(
    name: User.CreateBody.Name(first: "John", last: "Doe"),
    email: "john@example.com"
))

switch result {
case let (data?, nil):
    print("User created: \(data.user.name)")
case let (nil, error?):
    print("Error: \(error.name) - \(error.status)")
default:
    print("Unknown error")
}

Keywords

sdk

FAQs

Package last updated on 10 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.