From 5e3eca8edc57a0e38d449c8859bd5bc600ebbfeb Mon Sep 17 00:00:00 2001 From: Charlotte Som Date: Wed, 27 Nov 2024 05:38:46 +0200 Subject: [PATCH] v0.2.1: update README and fix serverName types --- README.md | 8 +++++--- deno.json | 2 +- ngx.ts | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 399d49d..9fae94e 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,20 @@ Opinionated nginx config generation for Deno. Generate an nginx configuration to permanently redirect some routes from a.com to their new locations at b.com: ```typescript -import ngx from "jsr:@char/ngx@0.1"; +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", [ [ - "server_name a.com", + ngx.serverName(DOMAIN), ...ngx.listen(), - ...ngx.letsEncrypt("a.com"), + ...ngx.letsEncrypt(DOMAIN), ], Object.entries(redirects).map(([path, uri]) => ngx(`location = ${path}`, [ diff --git a/deno.json b/deno.json index 0c30d45..f0cd8ca 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@char/ngx", - "version": "0.2.0", + "version": "0.2.1", "license": "WTFPL", "exports": "./ngx.ts" } diff --git a/ngx.ts b/ngx.ts index 7d1df7f..72c6c0c 100644 --- a/ngx.ts +++ b/ngx.ts @@ -1,4 +1,4 @@ -const NGX_VERSION = "0.2.0"; +const NGX_VERSION = "0.2.1"; type ConfigNode = ConfigStatement | ConfigBlock | ConfigBreak | ConfigFile; @@ -108,7 +108,8 @@ export const listen = (...extras: string[]) => `http2 on`, ]); -export const serverName = (name: string) => conform([`server_name ${name}`]); +export const serverName = (name: string) => + new ConfigStatement(`server_name ${name}`); export const letsEncrypt = ( domain: string,