Compare commits

...

2 Commits

2 changed files with 4 additions and 11 deletions

View File

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

View File

@ -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 })
}
@ -110,8 +104,8 @@ app.get('/printers/:name/jobs', (req, res) => {
// --- Print API ---
app.post('/print', bodyParser.raw({ type: '*/*', limit: MAX_SIZE_MB * 1_000_000 }), (req, res) => {
const { body, query, headers } = req
console.log("Received print job: ", { body, query, headers })
const { body, query } = req
console.log("Received print job: ", { body, query })
// validate query params
const { printer: printerName, copies: copiesParam, ...otherParams } = query