Skip to main content
Home

@char/ngx@0.2.1

latest

Opinionated nginx config generation for Deno

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
41%
Published
a year ago (0.2.1)

ngx

Opinionated nginx config generation for Deno.

Example

Generate an nginx configuration to permanently redirect some routes from a.com to their new locations at b.com:

import ngx from "jsr:@char/ngx@0.2";

const redirects = {
  "/a": "https://b.com/new-a",
  "/b": "https://b.com/b-v2",
};

const DOMAIN = "a.com";

const config = ngx("server", [
  [
    ngx.serverName(DOMAIN),
    ...ngx.listen(),
    ...ngx.letsEncrypt(DOMAIN),
  ],
  Object.entries(redirects).map(([path, uri]) =>
    ngx(`location = ${path}`, [
      `return 301 ${uri}`
    ])
  )
])

if (import.meta.main) console.log(config.build());

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@char/ngx

Import symbol

import * as ngx from "@char/ngx";
or

Import directly with a jsr specifier

import * as ngx from "jsr:@char/ngx";

Add Package

pnpm i jsr:@char/ngx
or (using pnpm 10.8 or older)
pnpm dlx jsr add @char/ngx

Import symbol

import * as ngx from "@char/ngx";

Add Package

yarn add jsr:@char/ngx
or (using Yarn 4.8 or older)
yarn dlx jsr add @char/ngx

Import symbol

import * as ngx from "@char/ngx";

Add Package

vlt install jsr:@char/ngx

Import symbol

import * as ngx from "@char/ngx";

Add Package

npx jsr add @char/ngx

Import symbol

import * as ngx from "@char/ngx";

Add Package

bunx jsr add @char/ngx

Import symbol

import * as ngx from "@char/ngx";