| j | 5050206 | 2022-01-24 19:25:49 -0800 | [diff] [blame] | 1 | /** |
| 2 | * @file DTPS development server |
| 3 | * @author jottocraft |
| 4 | * |
| j | 6e1a7bf | 2026-10-13 03:37:04 +0000 | [diff] [blame] | 5 | * @copyright Copyright (c) jottocraft 2020 |
| j | 5050206 | 2022-01-24 19:25:49 -0800 | [diff] [blame] | 6 | * @license MIT |
| 7 | */ |
| 8 | |
| 9 | const express = require('express'); |
| 10 | const app = express(); |
| 11 | |
| 12 | var port = 2750; |
| 13 | |
| 14 | //Check CLI args |
| 15 | process.argv.forEach(arg => { |
| 16 | if (arg.startsWith("--port=")) { |
| 17 | port = Number(arg.replace("--port=", "")); |
| 18 | } |
| 19 | }) |
| 20 | |
| 21 | //Serve dev |
| 22 | app.get('/dtps/dev', function(req, res) { |
| 23 | res.send(true); |
| 24 | }); |
| 25 | |
| 26 | //Serve scripts |
| 27 | app.use('/scripts', express.static('scripts')); |
| 28 | |
| j | dc6ea0e | 2022-04-26 16:03:27 -0700 | [diff] [blame] | 29 | //Serve root-level script |
| j | 5050206 | 2022-01-24 19:25:49 -0800 | [diff] [blame] | 30 | app.use('/init.js', express.static('init.js')); |
| j | dc6ea0e | 2022-04-26 16:03:27 -0700 | [diff] [blame] | 31 | |
| 32 | //Serve UI files |
| 33 | app.use('/dtps.css', express.static('ui/dtps.css')); |
| 34 | app.use('/fluid/fluid.css', express.static('ui/fluid.css')); |
| 35 | app.use('/fluid/fluid.js', express.static('ui/fluid.js')); |
| j | 5050206 | 2022-01-24 19:25:49 -0800 | [diff] [blame] | 36 | |
| 37 | //Serve www |
| 38 | app.use('/', express.static('www')); |
| 39 | |
| 40 | app.listen(port, () => { |
| 41 | console.log("The Power+ development server is listening on port " + port); |
| 42 | console.log("\nGo to Settings -> About -> Advanced Options -> Enable debug config in Power+ to enable debug mode"); |
| 43 | console.log("Read CONTRIBUTING.md for more information"); |
| 44 | }); |