v0.2.1: update README and fix serverName types

This commit is contained in:
Charlotte Som 2024-11-27 05:38:46 +02:00
parent c09f6fc96c
commit 5e3eca8edc
3 changed files with 9 additions and 6 deletions

View file

@ -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}`, [

View file

@ -1,6 +1,6 @@
{
"name": "@char/ngx",
"version": "0.2.0",
"version": "0.2.1",
"license": "WTFPL",
"exports": "./ngx.ts"
}

5
ngx.ts
View file

@ -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,