mirror of
https://github.com/EvolutionAPI/evolution-manager.git
synced 2025-12-19 11:32:18 -06:00
Fix file paths and error handling in server.js and
build.js
This commit is contained in:
@@ -11,20 +11,28 @@ const functions = {
|
||||
}
|
||||
|
||||
module.exports = async (argv) => {
|
||||
if (argv._.length === 1) throw new Error('No operation specified')
|
||||
try{
|
||||
|
||||
const operation = argv._[1]
|
||||
if (!functions[operation]) throw new Error(`Unknown operation: ${operation}`)
|
||||
|
||||
await functions[operation](argv)
|
||||
if (argv._.length === 1) throw new Error('No operation specified')
|
||||
|
||||
const operation = argv._[1]
|
||||
if (!functions[operation]) throw new Error(`Unknown operation: ${operation}`)
|
||||
|
||||
await functions[operation](argv)
|
||||
} catch (e) {
|
||||
console.error(e.message || e)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const path = require('path');
|
||||
|
||||
function startServer(argv) {
|
||||
const { port = 9615 } = argv || {}
|
||||
|
||||
const index = fs.readFileSync(process.cwd() + '/dist/index.html');
|
||||
const index = fs.readFileSync(path.join(__dirname, '..', 'dist', 'index.html'));
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
try {
|
||||
@@ -32,7 +40,7 @@ function startServer(argv) {
|
||||
|
||||
// verify if url is a file in dist folder
|
||||
if (parsedUrl.pathname === '/') throw {}
|
||||
let filePath = process.cwd() + '/dist' + parsedUrl.pathname;
|
||||
let filePath = path.join(__dirname, '..', 'dist', parsedUrl.pathname);
|
||||
|
||||
if (fs.existsSync(filePath)) {
|
||||
const contentType = mime.lookup(filePath) || 'text/plain';
|
||||
|
||||
Reference in New Issue
Block a user