LunarMelody / remix-koa-adapter

Koa request server handler for Remix

Home Page:https://www.npmjs.com/package/remix-koa-adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remix-koa-adapter

build npm version License: MIT

This is a server adapter for using koa with the Remix framework. It is more or less a straight-forward port of @remix-run/express.

Installation & Usage

  • npm install remix-koa-adapter (or use pnpm, yarn, etc)

The package exports a Remix server adapter with a createRequestHandler function. For more information on using Remix server adapters, please refer to the Remix documentation.

Usage Example:

import Koa from 'koa'
import serve from 'koa-static'
import path from 'path'
import { createRequestHandler } from 'remix-koa-adapter'

const app = new Koa()

const BUILD_DIR = path.join(process.cwd(), 'build')

app.use(serve('public'))

app.use(
	createRequestHandler({
		build: require(BUILD_DIR),
	})
)

const port = process.env.PORT ?? 3000
app.listen(port, () => {
	console.log(`✅ App listening on port ${port}`)
})

Contributing & Local Development

  • pnpm dev Run minimal remix example against the adapter.
  • pnpm test (or pnpm test:coverage) for running unit tests
  • pnpm build to build the library for publishing

In the playground directory, there is a minimal Remix application that can be run against the adapter to manually validate the its behavior. More thorough specs for the adapter can be found in the unit tests, which are ported from the unit tests for @remix-run/express, which I've considered the canonical adapter implementation for the purpose of this project.

Authors

License

MIT

About

Koa request server handler for Remix

https://www.npmjs.com/package/remix-koa-adapter

License:MIT License


Languages

Language:TypeScript 89.6%Language:JavaScript 9.5%Language:Shell 0.8%