1.0.4 • Published 9 months ago

dredge-adapters v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 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

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

10 months ago

0.5.8

10 months ago

0.5.7

11 months ago

0.5.9

10 months ago

0.5.6

11 months ago

0.5.5

11 months ago

0.5.4

11 months ago

0.5.2

11 months ago

0.5.1

11 months ago

0.5.0

11 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.0

11 months ago