remove unnecessary PRINTSERVANT_SECRET option
parent
8b1857bc3b
commit
2f64dae624
|
@ -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
|
||||
```
|
||||
|
||||
|
||||
|
|
8
index.js
8
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 })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue