(userConfig = {})
| 412 | * @returns {Tenso} An initialized Tenso server instance |
| 413 | */ |
| 414 | export function tenso (userConfig = {}) { |
| 415 | const config = merge(clone(defaultConfig), userConfig); |
| 416 | |
| 417 | if ((/^[^\d+]$/).test(config.port) && config.port < INT_1) { |
| 418 | console.error(INVALID_CONFIGURATION); |
| 419 | process.exit(INT_1); |
| 420 | } |
| 421 | |
| 422 | config.webroot.root = resolve(config.webroot.root); |
| 423 | config.webroot.template = readFileSync(config.webroot.template, {encoding: UTF8}); |
| 424 | |
| 425 | if (config.silent !== true) { |
| 426 | config.defaultHeaders.server = `${config.title.toLowerCase()}/${config.version}`; |
| 427 | config.defaultHeaders[X_POWERED_BY] = `nodejs/${process.version}, ${process.platform}/${process.arch}`; |
| 428 | } |
| 429 | |
| 430 | const app = new Tenso(config); |
| 431 | |
| 432 | return app.init(); |
| 433 | } |
no test coverage detected