From 2f64dae62486a879043d611e893263240f322fe6 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Feb 2024 12:19:05 +0100 Subject: [PATCH] remove unnecessary PRINTSERVANT_SECRET option --- README.md | 3 +-- index.js | 8 +------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3e7322e..c728100 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,11 @@ PRINTSERVANT_CONFIG - JSON config, like so: { name: 'DYMO_LabelWriter450', aliases: ['dymo', 'label'], - ipp_url: 'ipp://$SECRET@printmaster.waw.hackerspace.pl/printers/DYMO_LabelWriter450', + ipp_url: 'ipp://printmaster.waw.hackerspace.pl/printers/DYMO_LabelWriter450', }, ... ] } -PRINTSERVANT_SECRET - Optional, used to substitute $SECRET in printer configs' ipp_urls ``` diff --git a/index.js b/index.js index 3f3ecdf..884a36c 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,6 @@ const bodyParser = require('body-parser') const PORT = Number(process.env.PRINTSERVANT_PORT) || 3199 const CONFIG = JSON.parse(process.env.PRINTSERVANT_CONFIG || 'null') -const SECRET = process.env.PRINTSERVANT_SECRET || '' const MAX_SIZE_MB = Number(process.env.PRINTSERVANT_MAX_SIZE_MB) || 10 if (!(PORT && CONFIG)) { @@ -24,12 +23,7 @@ for (const printerConfig of CONFIG.printers) { throw new Error("Printer config must have a name and url") } - if (ipp_url.includes('$SECRET') && !SECRET) { - throw new Error(`Printer '${name}' config has a secret in the url but no PRINTSERVANT_CONFIG was provided`) - } - - const url = ipp_url.replace('$SECRET', SECRET) - const ippPrinter = ipp.Printer(url) + const ippPrinter = ipp.Printer(ipp_url) printers.push({ name, aliases, ippPrinter }) }