-
Notifications
You must be signed in to change notification settings - Fork 18
Read app path from applications file #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Change ECMAScript version in eslint config to pass linting. ECMAScript 2020 doesn't include private class fields that this project is using
.eslintrc.json
Outdated
@@ -6,7 +6,7 @@ | |||
}, | |||
"extends": "eslint:recommended", | |||
"parserOptions": { | |||
"ecmaVersion": 2020 | |||
"ecmaVersion": 2022 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ecmaVersion": 2022 | |
"ecmaVersion": "latest" |
main.js
Outdated
const { resolve } = require('node:path'); | ||
const { readFile } = require('node:fs/promises'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to have compound identifiers like path.resolve
in codebase below
main.js
Outdated
const appsFile = await readFile(resolve(appFilePath), { | ||
encoding: 'utf8', | ||
}); | ||
|
||
return appsFile.split('\n').filter((path) => path.trim() !== ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const appsFile = await readFile(resolve(appFilePath), { | |
encoding: 'utf8', | |
}); | |
return appsFile.split('\n').filter((path) => path.trim() !== ''); | |
const appsFile = path.resolve('.applications') | |
const apps = await readFile(appsFile, 'utf8'); | |
return apps.split('[\r\n\s]+').filter((s) => s.length !== 0); |
main.js
Outdated
|
||
const { Logger, StreamForLogger } = require('./src/logger.js'); | ||
const http = require('./src/http.js'); | ||
const ws = require('./src/ws.js'); | ||
const { loadApplication } = require('./src/loader.js'); | ||
|
||
const APPLICATION_PATH = path.join(process.cwd(), '../NodeJS-Application'); | ||
const APPLICATIONS_FILE_PATH = '.applications'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need no constant, string content is easy to understand
main.js
Outdated
|
||
return appsFile.split('\n').filter((path) => path.trim() !== ''); | ||
}; | ||
|
||
(async () => { | ||
const streamForLogger = new StreamForLogger(LOG_FOLDER_PATH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const streamForLogger = new StreamForLogger(LOG_FOLDER_PATH); | |
const stream = new StreamForLogger(LOG_FOLDER_PATH); |
main.js
Outdated
const server = fastify({ | ||
logger: { level: 'info', stream: streamForLogger }, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const server = fastify({ | |
logger: { level: 'info', stream: streamForLogger }, | |
}); | |
const server = fastify({ logger: { level: 'info', stream } }); |
Addresses #9