mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
It is basically a cosmetic thing, but has the following advantages: 1. Consistency with the official node documentation. The prefix is used there. 2. It is easier to recognize the build-in modules.
31 lines
671 B
JavaScript
31 lines
671 B
JavaScript
const path = require("node:path");
|
|
const auth = require("express-basic-auth");
|
|
const express = require("express");
|
|
|
|
const app = express();
|
|
|
|
const basicAuth = auth({
|
|
realm: "MagicMirror² Area restricted.",
|
|
users: { MagicMirror: "CallMeADog" }
|
|
});
|
|
|
|
app.use(basicAuth);
|
|
|
|
// Set available directories
|
|
const directories = ["/tests/configs", "/tests/mocks"];
|
|
const rootPath = path.resolve(`${__dirname}/../../../`);
|
|
|
|
for (let directory of directories) {
|
|
app.use(directory, express.static(path.resolve(rootPath + directory)));
|
|
}
|
|
|
|
let server;
|
|
|
|
exports.listen = (...args) => {
|
|
server = app.listen.apply(app, args);
|
|
};
|
|
|
|
exports.close = async () => {
|
|
await server.close();
|
|
};
|