forked from y-scope/clp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clp-package: Add the log-viewer and serve it using the log-viewer-web…
…ui. (y-scope#490)
- Loading branch information
Showing
7 changed files
with
134 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import path from "node:path"; | ||
import process from "node:process"; | ||
import {fileURLToPath} from "node:url"; | ||
|
||
import {fastifyStatic} from "@fastify/static"; | ||
|
||
import settings from "../../settings.json" with {type: "json"}; | ||
|
||
|
||
/** | ||
* Creates static files serving routes. | ||
* | ||
* @param {import("fastify").FastifyInstance} fastify | ||
* @param {import("fastify").FastifyPluginOptions} options | ||
*/ | ||
const routes = async (fastify, options) => { | ||
const filename = fileURLToPath(import.meta.url); | ||
const dirname = path.dirname(filename); | ||
const rootDirname = path.resolve(dirname, "../.."); | ||
|
||
let irFilesDir = settings.IrFilesDir; | ||
if (false === path.isAbsolute(irFilesDir)) { | ||
irFilesDir = path.resolve(rootDirname, irFilesDir); | ||
} | ||
await fastify.register(fastifyStatic, { | ||
prefix: "/ir", | ||
root: irFilesDir, | ||
}); | ||
|
||
let logViewerDir = settings.LogViewerDir; | ||
if (false === path.isAbsolute(logViewerDir)) { | ||
logViewerDir = path.resolve(rootDirname, logViewerDir); | ||
} | ||
await fastify.register(fastifyStatic, { | ||
prefix: "/log-viewer", | ||
root: logViewerDir, | ||
decorateReply: false, | ||
}); | ||
|
||
if ("production" === process.env.NODE_ENV) { | ||
// In the development environment, we expect the client to use a separate webserver that | ||
// supports live reloading. | ||
let clientDir = settings.ClientDir; | ||
if (false === path.isAbsolute(clientDir)) { | ||
clientDir = path.resolve(rootDirname, settings.ClientDir); | ||
} | ||
|
||
await fastify.register(fastifyStatic, { | ||
prefix: "/", | ||
root: clientDir, | ||
decorateReply: false, | ||
}); | ||
} | ||
}; | ||
|
||
export default routes; |
Submodule yscope-log-viewer
added at
df996e