-
Notifications
You must be signed in to change notification settings - Fork 20
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?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,25 +1,38 @@ | ||||||||||||||||||
| 'use strict'; | ||||||||||||||||||
|
|
||||||||||||||||||
| const fastify = require('fastify'); | ||||||||||||||||||
| const { resolve } = require('node:path'); | ||||||||||||||||||
| const { readFile } = require('node:fs/promises'); | ||||||||||||||||||
|
||||||||||||||||||
|
|
||||||||||||||||||
| const path = require('node:path'); | ||||||||||||||||||
| const fastify = require('fastify'); | ||||||||||||||||||
|
|
||||||||||||||||||
| 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'; | ||||||||||||||||||
|
||||||||||||||||||
| const LOG_FOLDER_PATH = './log'; | ||||||||||||||||||
|
|
||||||||||||||||||
| const getAppPaths = async (appFilePath) => { | ||||||||||||||||||
| const appsFile = await readFile(resolve(appFilePath), { | ||||||||||||||||||
| encoding: 'utf8', | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| return appsFile.split('\n').filter((path) => path.trim() !== ''); | ||||||||||||||||||
|
||||||||||||||||||
| 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); |
Outdated
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); |
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 } }); |
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.