Skip to main content

@char/ngx@0.1.1

latest

Opinionated nginx config generation for Deno

Works with
This package works with Deno
JSR Score
35%
Published
3 months ago (0.1.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.1";

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

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

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

Add Package

deno add @char/ngx

Import symbol

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