A middleware framework for handling HTTP with Deno, Node, Bun and Cloudflare Workers 🐿️ 🦕
oak 10.3 introduces experimental support for Node.js 16.5 and later.
The package is available on npm as
@oakserver/oak
and can be
installed with your preferred package manager.
The package shares the same API as if it were being used under Deno CLI or Deno Deploy, and almost all functionality is the same.
A few notes about the support:
Headers
from undici
which operate slightly different than the Deno Headers
class. Generally this
shouldn’t cause issues for users and code, but it hasn’t been extensively
tested yet and so there maybe some behavioral changes.FormData
bodies that need to write out files to the file system do
not work properly. This will be fixed in the future.As mentioned above, installing the package @oakserver/oak
should be
sufficient.
If you love kittens, you should consider using ES modules in Node.js and
importing from "@oakserver/oak"
:
index.mjs
import { Application } from "@oakserver/oak";
const app = new Application();
app.use((ctx) => {
ctx.response.body = "Hello from oak on Node.js";
});
app.listen({ port: 8000 });
If you want to import it in a CommonJS module, require()
can be used:
index.js
const { Application } = require("@oakserver/oak");
const app = new Application();
app.use((ctx) => {
ctx.response.body = "Hello from oak on Node.js";
});
app.listen({ port: 8000 });