Skip to main content

Built and signed on GitHub Actions

NestJS HTTP adapter for Oak and Deno

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
a week ago (0.1.2)

nestjs-platform-oak

NestJS HTTP adapter for Oak.

Installation

$ deno add @uki00a/nestjs-platform-oak @oak/oak npm:@nestjs/common npm:@nestjs/core

Usage

import { NestFactory } from "@nestjs/core";
import { Application } from "@oak/oak";
import { OakAdapter } from "@uki00a/nestjs-platform-oak";
import { AppModule } from "@/app.module.ts";

const app = await NestFactory.create(
  AppModule,
  OakAdapter.create(new Application()),
);
await app.listen(3000);

Limitations

@Body() decorator with key parameter does not work

If you specify key parameter to the @Body() decorator as shown below, it will not work as intended:

import { Body, Controller, Post } from "@nestjs/common";
import type { Request } from "@oak/oak";

@Controller("/tags")
export class TagsController {
  @Post()
  createTag(@Body("name") tagName: string) {
    return { name: tagName };
  }
}

This is because Oak's Request.body is not a plain object. In this case you should use @JsonBody() decorator instead:

import { Controller, Post } from "@nestjs/common";
import { JsonBody } from "@uki00a/nestjs-platform-oak";
import type { Request } from "@oak/oak";

@Controller("/tags")
export class TagsController {
  @Post()
  createTag(@JsonBody("name") tagName: string) {
    return { name: tagName };
  }
}
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@uki00a/nestjs-platform-oak

Import symbol

import * as mod from "@uki00a/nestjs-platform-oak";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@uki00a/nestjs-platform-oak";

Add Package

npx jsr add @uki00a/nestjs-platform-oak

Import symbol

import * as mod from "@uki00a/nestjs-platform-oak";

Add Package

yarn dlx jsr add @uki00a/nestjs-platform-oak

Import symbol

import * as mod from "@uki00a/nestjs-platform-oak";

Add Package

pnpm dlx jsr add @uki00a/nestjs-platform-oak

Import symbol

import * as mod from "@uki00a/nestjs-platform-oak";

Add Package

bunx jsr add @uki00a/nestjs-platform-oak

Import symbol

import * as mod from "@uki00a/nestjs-platform-oak";