mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-14 07:39:29 -07:00
convert server to mjs
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
node_modules
|
||||
**/debug.log
|
||||
server/scripts/custom.js
|
||||
server/scripts/custom.js
|
||||
music
|
||||
|
||||
|
||||
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -50,7 +50,7 @@
|
||||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
],
|
||||
"program": "${workspaceFolder}/index.js",
|
||||
"program": "${workspaceFolder}/index.mjs",
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
@@ -59,7 +59,7 @@
|
||||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
],
|
||||
"program": "${workspaceFolder}/index.js",
|
||||
"program": "${workspaceFolder}/index.mjs",
|
||||
"env": {
|
||||
"DIST": "1"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// pass through api requests
|
||||
|
||||
// http(s) modules
|
||||
const https = require('https');
|
||||
import https from 'https';
|
||||
|
||||
// url parsing
|
||||
const queryString = require('querystring');
|
||||
import queryString from 'querystring';
|
||||
|
||||
// return an express router
|
||||
module.exports = (req, res) => {
|
||||
const cors = (req, res) => {
|
||||
// add out-going headers
|
||||
const headers = {};
|
||||
headers['user-agent'] = '(WeatherStar 4000+, ws4000@netbymatt.com)';
|
||||
@@ -41,3 +41,5 @@ module.exports = (req, res) => {
|
||||
console.error(e);
|
||||
});
|
||||
};
|
||||
|
||||
export default cors;
|
||||
@@ -1,13 +1,13 @@
|
||||
// pass through api requests
|
||||
|
||||
// http(s) modules
|
||||
const https = require('https');
|
||||
import https from 'https';
|
||||
|
||||
// url parsing
|
||||
const queryString = require('querystring');
|
||||
import queryString from 'querystring';
|
||||
|
||||
// return an express router
|
||||
module.exports = (req, res) => {
|
||||
const outlook = (req, res) => {
|
||||
// add out-going headers
|
||||
const headers = {};
|
||||
headers['user-agent'] = '(WeatherStar 4000+, ws4000@netbymatt.com)';
|
||||
@@ -42,3 +42,5 @@ module.exports = (req, res) => {
|
||||
console.error(e);
|
||||
});
|
||||
};
|
||||
|
||||
export default outlook;
|
||||
@@ -1,13 +1,13 @@
|
||||
// pass through api requests
|
||||
|
||||
// http(s) modules
|
||||
const https = require('https');
|
||||
import https from 'https';
|
||||
|
||||
// url parsing
|
||||
const queryString = require('querystring');
|
||||
import queryString from 'querystring';
|
||||
|
||||
// return an express router
|
||||
module.exports = (req, res) => {
|
||||
const radar = (req, res) => {
|
||||
// add out-going headers
|
||||
const headers = {};
|
||||
headers['user-agent'] = '(WeatherStar 4000+, ws4000@netbymatt.com)';
|
||||
@@ -42,3 +42,5 @@ module.exports = (req, res) => {
|
||||
console.error(e);
|
||||
});
|
||||
};
|
||||
|
||||
export default radar;
|
||||
@@ -1,19 +1,15 @@
|
||||
// express
|
||||
const express = require('express');
|
||||
import express from 'express';
|
||||
import fs from 'fs';
|
||||
import corsPassThru from './cors/index.mjs';
|
||||
import radarPassThru from './cors/radar.mjs';
|
||||
import outlookPassThru from './cors/outlook.mjs';
|
||||
|
||||
const app = express();
|
||||
const port = process.env.WS4KP_PORT ?? 8080;
|
||||
const path = require('path');
|
||||
|
||||
// template engine
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
// cors pass through
|
||||
const fs = require('fs');
|
||||
const corsPassThru = require('./cors');
|
||||
const radarPassThru = require('./cors/radar');
|
||||
const outlookPassThru = require('./cors/outlook');
|
||||
|
||||
// cors pass-thru to api.weather.gov
|
||||
app.get('/stations/*', corsPassThru);
|
||||
app.get('/Conus/*', radarPassThru);
|
||||
@@ -23,7 +19,7 @@ app.get('/products/*', outlookPassThru);
|
||||
const { version } = JSON.parse(fs.readFileSync('package.json'));
|
||||
|
||||
const index = (req, res) => {
|
||||
res.render(path.join(__dirname, 'views/index'), {
|
||||
res.render('index', {
|
||||
production: false,
|
||||
version,
|
||||
});
|
||||
@@ -32,15 +28,15 @@ const index = (req, res) => {
|
||||
// debugging
|
||||
if (process.env?.DIST === '1') {
|
||||
// distribution
|
||||
app.use('/images', express.static(path.join(__dirname, './server/images')));
|
||||
app.use('/fonts', express.static(path.join(__dirname, './server/fonts')));
|
||||
app.use('/scripts', express.static(path.join(__dirname, './server/scripts')));
|
||||
app.use('/', express.static(path.join(__dirname, './dist')));
|
||||
app.use('/images', express.static('./server/images'));
|
||||
app.use('/fonts', express.static('./server/fonts'));
|
||||
app.use('/scripts', express.static('./server/scripts'));
|
||||
app.use('/', express.static('./dist'));
|
||||
} else {
|
||||
// debugging
|
||||
app.get('/index.html', index);
|
||||
app.get('/', index);
|
||||
app.get('*', express.static(path.join(__dirname, './server')));
|
||||
app.get('*', express.static('./server'));
|
||||
}
|
||||
|
||||
const server = app.listen(port, () => {
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "ws4kp",
|
||||
"version": "5.14.3",
|
||||
"description": "Welcome to the WeatherStar 4000+ project page!",
|
||||
"main": "index.js",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build:css": "sass --style=compressed ./server/styles/scss/main.scss ./server/styles/main.css",
|
||||
@@ -48,4 +49,4 @@
|
||||
"express": "^4.17.1",
|
||||
"ejs": "^3.1.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
server/styles/scss/_media.scss
Normal file
3
server/styles/scss/_media.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.media {
|
||||
display: none;
|
||||
}
|
||||
@@ -11,4 +11,5 @@
|
||||
@import 'radar';
|
||||
@import 'regional-forecast';
|
||||
@import 'almanac';
|
||||
@import 'hazards';
|
||||
@import 'hazards';
|
||||
@import 'media';
|
||||
0
src/music-list.mjs
Normal file
0
src/music-list.mjs
Normal file
@@ -131,6 +131,7 @@
|
||||
<img id="NavigateRefresh" class="navButton" src="images/nav/ic_refresh_white_24dp_2x.png" title="Refresh" />
|
||||
</div>
|
||||
<div id="divTwcBottomRight">
|
||||
<img id="ToggleMedia" class="navButton" src="images/nav/ic_volume_off_white_24dp_2x.png" title="Unmute" />
|
||||
<img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_white_24dp_2x.png" title="Enter Fullscreen" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -141,6 +142,7 @@
|
||||
<div class="info">
|
||||
<a href="https://github.com/netbymatt/ws4kp#weatherstar-4000">More information</a>
|
||||
</div>
|
||||
<div class="media"></div>
|
||||
|
||||
<div class='heading'>Selected displays</div>
|
||||
<div id='enabledDisplays'>
|
||||
|
||||
Reference in New Issue
Block a user