Skip to main content

Launch your server

With Node HTTP​

Example​

server.ts
ts
import { initBridge, handler } from 'bridge';
 
const hello = handler({
resolve: () => 'hello',
});
 
const bridge = initBridge({ routes: { hello } });
 
const port = 8080;
 
bridge.HTTPServer().listen(port, () => {
`Listening on port ${port}`;
});
server.ts
ts
import { initBridge, handler } from 'bridge';
 
const hello = handler({
resolve: () => 'hello',
});
 
const bridge = initBridge({ routes: { hello } });
 
const port = 8080;
 
bridge.HTTPServer().listen(port, () => {
`Listening on port ${port}`;
});

With Express​

Install express​

terminal
bash
npm i express
npm i --save-dev @types/express
terminal
bash
npm i express
npm i --save-dev @types/express

Example​

server.ts
ts
import { initBridge, handler } from 'bridge';
import express from 'express';
 
const hello = handler({
resolve: () => 'hello',
});
 
const bridge = initBridge({ routes: { hello } });
 
const port = 8080;
 
const app = express();
 
app.use('', bridge.expressMiddleware());
 
app.listen(port, () => {
`Listening on port ${port}`;
});
server.ts
ts
import { initBridge, handler } from 'bridge';
import express from 'express';
 
const hello = handler({
resolve: () => 'hello',
});
 
const bridge = initBridge({ routes: { hello } });
 
const port = 8080;
 
const app = express();
 
app.use('', bridge.expressMiddleware());
 
app.listen(port, () => {
`Listening on port ${port}`;
});

With Fastify​

Coming soon...

Lambda​

Coming soon...