MCPcopy Index your code
hub / github.com/bridge-codes/bridge

github.com/bridge-codes/bridge @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
205 symbols 407 edges 128 files 1 documented · 0% updated 19mo ago★ 3333 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Twitter Discord MIT License

Bridge

Bridge is the most straightforward yet powerful framework for creating simple or complex APIs using the full power of TypeScript, even for developers with little experience. Give it a try and see how easy it is to build your dream API!

Documentation

Full documentation for bridge can be found here.

Installation

# npm
npm install bridge
# Yarn
yarn add bridge
# pnpm
pnpm add bridge

Quickstart

# npm
npx create-bridge-app@latest
# Yarn
yarn create bridge-app
# pnpm
pnpm create bridge-app

Basic Example

import { initBridge, handler } from 'bridge';
import express from 'express';
// You can also use Yup or Superstruct for data validation
import z from 'zod';

const port = 8080;

// A handler can be used as an endpoint but also as a middleware
const heyHandler = handler({
  query: z.object({ name: z.string() }),
  resolve: ({ query }) => `Hey ${query.name}`,
});

// You can also have multiple endpoints for the same route with different methods with the method function
const routes = {
  hey: heyHandler, // POST /hey
};

// It is also possible to use pure HTTP Server
const app = express();

app.use('', initBridge({ routes }).expressMiddleware());

app.listen(port, () => {
  console.log(`Listening on port ${port}`);
});

For more complex examples and a full understanding of the capabilities of Bridge, be sure to check out our documentation!

Client code generation and documentation

Connect your Bridge API to Bridge Studio

With the CLI

```bash title='terminal' npx bridge-studio@latest

or

pnpx bridge-studio@latest


**With the plateform:** https://studio.bridge.codes


### Fetch your client SDK

```bash title='terminal'
npx fetch-bridge-sdk@latest {username}/{projectName}

Access your generated documentation

You'll be able to access your complete generated documentation on https://studio.bridge.codes soon.

Please visit https://bridge.codes/studio for more information.

Extension points exported contracts — how you extend this code

TypeViewInferface (Interface)
(no doc)
www/src/components/NewCode.tsx
HandlerParams (Interface)
(no doc)
packages/bridge/source/core/handler.ts
ReturnBridgeType (Interface)
(no doc)
packages/bridge-compile/bin/types.ts
FETCH (Interface)
(no doc)
packages/bridge-studio/sdk/bridgeFetchMethod.ts
FETCH (Interface)
(no doc)
examples/minimal-http/sdk/bridgeFetchMethod.ts
FETCH (Interface)
(no doc)
examples/minimal-express/sdk/bridgeFetchMethod.ts
FETCH (Interface)
(no doc)
examples/bridge-mongodb-boilerplate/sdk/bridgeFetchMethod.ts
PositionInterface (Interface)
(no doc)
www/src/components/NewCode.tsx

Core symbols most depended-on inside this repo

track
called by 10
www/src/analytics/mixpanel.ts
toString
called by 8
packages/bridge/source/utilities/formidable.ts
setNext
called by 6
packages/bridge/source/core/handler.ts
isJSONHandler
called by 6
packages/bridge-compile/bin/openapi.ts
httpError
called by 4
packages/bridge/source/error/index.ts
JSONTypeToTSInterface
called by 4
packages/bridge-compile/bin/sdk-compilers/typescript/json-type-to-ts-interface.ts
initBridge
called by 3
packages/bridge/source/bridge.ts
handler
called by 3
packages/bridge/source/core/index.ts

Shape

Function 122
Interface 55
Class 17
Method 10
Enum 1

Languages

TypeScript100%

Modules by API surface

packages/bridge-compile/bin/types.ts38 symbols
www/src/pages/studio.tsx14 symbols
www/src/pages/index.tsx10 symbols
packages/bridge/source/core/handler.ts8 symbols
www/src/components/NewCode.tsx7 symbols
packages/bridge-studio/bin/index.ts6 symbols
packages/bridge-compile/bin/parser/transform-json-type.ts6 symbols
packages/bridge-compile/bin/index.ts6 symbols
www/src/components/Code.tsx5 symbols
packages/bridge/source/routes/method.ts5 symbols
packages/bridge/source/core/handlers/bridge.ts5 symbols
packages/bridge-compile/bin/sdk-compilers/utils.ts5 symbols

Datastores touched

(mongodb)Database · 1 repos

For agents

$ claude mcp add bridge \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact