Skip to main content

@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
3 months 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());

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

npx jsr add @char/ngx

Import symbol

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

Add Package

yarn dlx jsr add @char/ngx

Import symbol

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

Add Package

pnpm dlx 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";