1.0.4 • Published 11 months ago

dredge-adapters v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

dredge-adapters

Install

npm install dredge-adapters

Usage

// standalone server
import { createHTTPServer } from 'dredge-adapters'
import { rootRouter } from './root-router'

const server = createServer({
    router: rootRouter,
    ctx: {},
})

server.listen(3000)
// using express
import express from "express";
import { dredgeRouter, dredgeRoute } from "dredge-route";
import {
  createNodeHttpRequestHandler,
} from "dredge-adapters";
import { rootRouter } from "./router";

const app = express();

app.use((req, res) => {
  const handler = createNodeHttpRequestHandler({
    router: rootRouter,
    ctx: {},
    dataSerializers: {
      "application/json": async ({ data }) => {
        return JSON.stringify(data);
      },
    },
    bodyParsers: {
      "application/json": async ({ text }) => {
        return JSON.parse(await text());
      },
    },
    prefixUrl: "http://localhost:3000",
  });

  handler(req, res);
});


app.listen(3000, () => {
  console.log("Server is running on port 3000");
});
1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

12 months ago

0.5.8

1 year ago

0.5.7

1 year ago

0.5.9

12 months ago

0.5.6

1 year ago

0.5.5

1 year ago

0.5.4

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago