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