@metoceanapi/wxtiles-leaflet 1.0.6 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,191 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>WxTiles v2.0</title>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <link rel="shortcut icon" href="res/icon.png" type="image/x-icon" />
8
-
9
- <!-- LEAFLET lib goes first -->
10
- <link
11
- rel="stylesheet"
12
- href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
13
- integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
14
- crossorigin=""
15
- />
16
-
17
- <script
18
- src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
19
- integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
20
- crossorigin=""
21
- ></script>
22
-
23
- <!-- WxTile lib goes here -->
24
- <script src="../dist/web/wxtile.js"></script>
25
- <link rel="stylesheet" href="../dist/web/wxtile.css" />
26
- </head>
27
-
28
- <body style="margin: 0">
29
- <div style="margin: 20px">
30
- Select style:
31
- <select id="selectStyle" onchange="setStyle(this.value)"></select>
32
- </div>
33
- <div>
34
- <div id="units"></div>
35
- <canvas id="legend" width="600" height="40"></canvas>
36
- </div>
37
-
38
- <div id="map" style="height: 100vh; width: 100vw"></div>
39
-
40
- <script>
41
- ('use strict');
42
- const { WxTileLogging, WxTileLibSetup, WxTileWatermark, WxTileLayer, WxGetColorStyles } = window.wxtilejs;
43
-
44
- // Leaflet basic setup // set the main Leaflet's map object, compose and add base layers
45
- const map = L.map('map', { center: [-37.803113, 174.878166], zoom: 5, zoomControl: false });
46
-
47
- WxTileLogging(true); // use wxtiles logging -> console.log
48
- WxTileWatermark({ URI: 'res/wxtiles-logo.png', position: 'topleft' }).addTo(map); // set the correct URI
49
- // ESSENTIAL step to get lib ready.
50
- const cusomStyles = {
51
- super: { name: 'Super custom style', colorScheme: 'redish', units: 'C' },
52
- };
53
- WxTileLibSetup({ colorStyles: cusomStyles }); // if empty defaults are used
54
-
55
- // SCALAR field setup
56
- const layerS = WxTileLayer({
57
- dataSource: {
58
- serverURI: 'https://tiles.metoceanapi.com/data', // server to fetch data from
59
- ext: 'png', // png / webp (default) - wxtilesplitter output format
60
- dataset: 'ecwmf.global', // dataset of the dataset
61
- variables: ['air.temperature.at-2m'], // variable(s) to be used for the layer rendering
62
- name: 'air.temperature.at-2m', // attribute of the dataSource to be used externally
63
- styleName: 'base', // The name of the style (from styles.json) to apply for the layer
64
- },
65
- // Lazy setup
66
- // 'true': perform setup and data loading on 'addTo(map)'.
67
- // 'false': start loading immediately, but loading is not finished when layer is created.
68
- // the signal 'setupcomplete' is fired when loading is finished.
69
- // useful when a big bunch of layers is used, so layers are not wasting memory and bandwidth.
70
- lazy: false,
71
- options: {
72
- opacity: 0.99,
73
- },
74
- });
75
- layerS.addTo(map);
76
-
77
- //STYLES
78
- // let's fill up 'selectStyleEl' selector
79
- const selectStyleEl = document.getElementById('selectStyle');
80
-
81
- const styles = WxGetColorStyles(); // all available styles. Not every style is sutable for this layer.
82
- for (const style in styles) {
83
- // For instance, let's select only styles that contain dataSource's name.
84
- const opt = document.createElement('option');
85
- opt.appendChild(document.createTextNode(styles[style].name));
86
- opt.value = style;
87
- selectStyleEl.appendChild(opt);
88
- }
89
-
90
- layerS.once('setupcomplete', () => {
91
- console.log('once: setup complete');
92
- // to make
93
- selectStyleEl.value = layerS.getStyle();
94
- window.setStyle(layerS.getStyle());
95
- });
96
-
97
- // FUNCs section
98
- window.setStyle = function (val) {
99
- const unitsEl = document.getElementById('units');
100
- const canvasEl = document.getElementById('legend');
101
- layerS.setStyle(val);
102
-
103
- // getLegendData - data to render a proper legend
104
- // pixSize - width of a canvas to render this legend
105
- // output:
106
- // legend - object
107
- // legend.units - (string) units
108
- // legend.colors - ([int32]) pixSize array of colors RGBA.
109
- // legend.ticks - ([tick])aray of ticks
110
- // tick.data - (float) data in legend units
111
- // tick.color - (string) representation of a color at this tick
112
- // tick.pos - (int) position in pixels of this tick on the legend.
113
- const legend = layerS.getLegendData(canvasEl.width - 50);
114
-
115
- unitsEl.innerHTML = 'Style: ' + layerS.getStyleName();
116
- drawLegend({ legend, canvas: canvasEl });
117
- };
118
-
119
- function drawLegend({ legend, canvas }) {
120
- if (!canvas || !legend) return;
121
-
122
- const { width, height } = canvas;
123
- const halfHeight = (16 + height) >> 2;
124
-
125
- // draw legend
126
- const ctx = canvas.getContext('2d');
127
- const imData = ctx.createImageData(width, height);
128
- const im = new Uint32Array(imData.data.buffer);
129
- im.fill(-1);
130
-
131
- const startX = 2;
132
- const startY = 2;
133
- const startXY = startX + width * startY;
134
-
135
- const trSize = halfHeight >> 1;
136
- // left triangle
137
- if (legend.showBelowMin) {
138
- const c = legend.colors[0];
139
- if (c) {
140
- for (let x = 0; x < trSize; ++x) {
141
- for (let y = trSize; y < trSize + x; ++y) {
142
- im[startXY + x + y * width] = c;
143
- im[startXY + x + (trSize * 2 - y) * width] = c;
144
- }
145
- }
146
- }
147
- }
148
-
149
- for (let x = 0; x < legend.size; ++x) {
150
- for (let y = 0; y < halfHeight; ++y) {
151
- if (legend.colors[0]) {
152
- im[startX + x + trSize + (y + startY + 1) * width] = legend.colors[x];
153
- }
154
- }
155
- }
156
-
157
- // right triangle
158
- if (legend.showAboveMax) {
159
- const c = legend.colors[legend.colors.length - 1];
160
- if (c) {
161
- for (let x = 0; x <= trSize; ++x) {
162
- for (let y = trSize; y < trSize + x; ++y) {
163
- im[startXY + trSize * 2 + legend.size - x + y * width] = c;
164
- im[startXY + trSize * 2 + legend.size - x + (trSize * 2 - y) * width] = c;
165
- }
166
- }
167
- }
168
- }
169
-
170
- ctx.putImageData(imData, 0, 0);
171
-
172
- // draw ticks
173
- ctx.font = '8px sans-serif';
174
- ctx.beginPath();
175
- for (const tick of legend.ticks) {
176
- ctx.strokeStyle = '#000';
177
- ctx.moveTo(tick.pos + trSize + startX + 1, startY + 3);
178
- ctx.lineTo(tick.pos + trSize + startX + 1, halfHeight);
179
- ctx.fillText(tick.dataString, tick.pos + trSize + startX + 1, halfHeight + 11);
180
- }
181
- ctx.font = '12px sans-serif';
182
- const txt = 'Units: ' + legend.units;
183
- ctx.fillText(txt, 13, height - 5);
184
- ctx.stroke();
185
-
186
- ctx.strokeStyle = '#888';
187
- ctx.strokeRect(1, 1, width - 3, height - 2); //for white background
188
- }
189
- </script>
190
- </body>
191
- </html>
@@ -1,93 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>WxTiles v2.0</title>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <link rel="shortcut icon" href="res/icon.png" type="image/x-icon" />
8
-
9
- <!-- LEAFLET lib goes first -->
10
- <link
11
- rel="stylesheet"
12
- href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
13
- integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
14
- crossorigin=""
15
- />
16
-
17
- <script
18
- src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
19
- integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
20
- crossorigin=""
21
- ></script>
22
-
23
- <!-- WxTile lib goes here -->
24
- <script src="../dist/web/wxtile.js"></script>
25
- <link rel="stylesheet" href="../dist/web/wxtile.css" />
26
- </head>
27
-
28
- <body style="margin: 0">
29
- <div style="margin: 20px">
30
- Select time:
31
- <select id="selectTime" onchange="setTime(this.value)"></select>
32
- </div>
33
-
34
- <div id="map" style="height: 100vh; width: 100vw"></div>
35
-
36
- <script>
37
- ('use strict');
38
- const { WxTileLogging, WxTileLibSetup, WxTileWatermark, WxTileLayer, WxGetColorStyles } = window.wxtilejs;
39
-
40
- // Leaflet basic setup // set the main Leaflet's map object, compose and add base layers
41
- const map = L.map('map', { center: [-37.803113, 174.878166], zoom: 5, zoomControl: false });
42
-
43
- WxTileLogging(true); // use wxtiles logging -> console.log
44
- WxTileWatermark({ URI: 'res/wxtiles-logo.png', position: 'topleft' }).addTo(map); // set the correct URI
45
- // ESSENTIAL step to get lib ready.
46
- WxTileLibSetup(); // if empty defaults are used
47
-
48
- // SCALAR field setup
49
- const layerS = WxTileLayer({
50
- dataSource: {
51
- serverURI: 'https://tiles.metoceanapi.com/data', // server to fetch data from
52
- ext: 'png', // png / webp (default) - wxtilesplitter output format
53
- dataset: 'ecwmf.global', // dataset of the dataset
54
- variables: ['air.temperature.at-2m'], // variable(s) to be used for the layer rendering
55
- name: 'air.temperature.at-2m', // attribute of the dataSource to be used externally
56
- styleName: 'base', // The name of the style (from styles.json) to apply for the layer
57
- },
58
- // Lazy setup
59
- // 'true': perform setup and data loading on 'addTo(map)'.
60
- // 'false': start loading immediately, but loading is not finished when layer is created.
61
- // the signal 'setupcomplete' is fired when loading is finished.
62
- // useful when a big bunch of layers is used, so layers are not wasting memory and bandwidth.
63
- lazy: false,
64
- options: {
65
- opacity: 0.99,
66
- },
67
- });
68
- layerS.addTo(map);
69
-
70
- // TIMES
71
- // instead of layerS.once('setupcomplete') setupCompletePromise can be used
72
- layerS.setupCompletePromise.then(() => {
73
- // once layer setup finished, times are available.
74
- // let's fill up 'selectTimeEl'
75
- const selectTimeEl = document.getElementById('selectTime');
76
- layerS.getTimes().forEach((val) => {
77
- const opt = document.createElement('option');
78
- opt.appendChild(document.createTextNode(val));
79
- opt.value = val;
80
- selectTimeEl.appendChild(opt);
81
- });
82
- selectTimeEl.value = layerS.getTime();
83
- });
84
-
85
- // FUNCs section
86
-
87
- window.setTime = function (val) {
88
- const d = new Date(val).getTime();
89
- layerS.setTime(d);
90
- };
91
- </script>
92
- </body>
93
- </html>
@@ -1,71 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>WxTiles v2.0</title>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <link rel="shortcut icon" href="res/icon.png" type="image/x-icon" />
8
-
9
- <!-- LEAFLET lib goes first -->
10
- <link
11
- rel="stylesheet"
12
- href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
13
- integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
14
- crossorigin=""
15
- />
16
-
17
- <script
18
- src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
19
- integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
20
- crossorigin=""
21
- ></script>
22
-
23
- <!-- WxTile lib goes here -->
24
- <script src="../dist/web/wxtile.js"></script>
25
- <link rel="stylesheet" href="../dist/web/wxtile.css" />
26
- </head>
27
-
28
- <body style="margin: 0">
29
- <div id="map" style="height: 100vh; width: 100vw"></div>
30
-
31
- <script>
32
- ('use strict');
33
- const { WxTileLogging, WxTileLibSetup, WxTileWatermark, WxTileLayer, WxGetColorStyles } = window.wxtilejs;
34
-
35
- // Leaflet basic setup // set the main Leaflet's map object, compose and add base layers
36
- const map = L.map('map', { center: [-37.803113, 174.878166], zoom: 5, zoomControl: false });
37
-
38
- WxTileLogging(true); // use wxtiles logging -> console.log
39
- WxTileWatermark({ URI: 'res/wxtiles-logo.png', position: 'topleft' }).addTo(map); // set the correct URI
40
- // ESSENTIAL step to get lib ready.
41
- WxTileLibSetup(); // if empty defaults are used
42
-
43
- // SCALAR field setup
44
- const layerS = WxTileLayer({
45
- dataSource: {
46
- serverURI: 'https://tiles.metoceanapi.com/data/', // server to fetch data from
47
- ext: 'png', // png / webp (default) - wxtilesplitter output format
48
- dataset: 'ecwmf.global', // dataset of the dataset
49
- variables: ['air.temperature.at-2m'], // variable(s) to be used for the layer rendering
50
- name: 'air.temperature.at-2m', // attribute of the dataSource to be used externally
51
- styleName: 'base', // The name of the style (from styles.json) to apply for the layer
52
- },
53
- // Lazy setup
54
- // 'true': perform setup and data loading on 'addTo(map)'.
55
- // 'false': start loading immediately, but loading is not finished when layer is created.
56
- // the signal 'setupcomplete' is fired when loading is finished.
57
- // useful when a big bunch of layers is used, so layers are not wasting memory and bandwidth.
58
- lazy: true,
59
- options: {
60
- opacity: 0.99,
61
- },
62
- });
63
- layerS.addTo(map);
64
-
65
- // due to loadings, setup takes time. 'WxTileLayer(...)' nor '.addTo(map)' finish
66
- layerS.once('setupcomplete', () => {
67
- window.alert('"once" setup complete');
68
- });
69
- </script>
70
- </body>
71
- </html>
@@ -1,71 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>WxTiles v2.0</title>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <link rel="shortcut icon" href="res/icon.png" type="image/x-icon" />
8
-
9
- <!-- LEAFLET lib goes first -->
10
- <link
11
- rel="stylesheet"
12
- href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
13
- integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
14
- crossorigin=""
15
- />
16
-
17
- <script
18
- src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
19
- integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
20
- crossorigin=""
21
- ></script>
22
-
23
- <!-- WxTile lib goes here -->
24
- <script src="../dist/web/wxtile.js"></script>
25
- <link rel="stylesheet" href="../dist/web/wxtile.css" />
26
- </head>
27
-
28
- <body style="margin: 0">
29
- <div id="map" style="height: 100vh; width: 100vw"></div>
30
-
31
- <script>
32
- ('use strict');
33
- const { WxTileLogging, WxTileLibSetup, WxTileWatermark, WxTileLayer, WxGetColorStyles } = window.wxtilejs;
34
-
35
- // Leaflet basic setup // set the main Leaflet's map object, compose and add base layers
36
- const map = L.map('map', { center: [-37.803113, 174.878166], zoom: 5, zoomControl: false });
37
-
38
- WxTileLogging(true); // use wxtiles logging -> console.log
39
- WxTileWatermark({ URI: 'res/wxtiles-logo.png', position: 'topleft' }).addTo(map); // set the correct URI
40
- // ESSENTIAL step to get lib ready.
41
- WxTileLibSetup(); // if empty defaults are used
42
-
43
- // SCALAR field setup
44
- const layerS = WxTileLayer({
45
- dataSource: {
46
- serverURI: 'https://tiles.metoceanapi.com/data/', // server to fetch data from
47
- ext: 'png', // png / webp (default) - wxtilesplitter output format
48
- dataset: 'ecwmf.global', // dataset of the dataset
49
- variables: ['air.temperature.at-2m'], // variable(s) to be used for the layer rendering
50
- name: 'air.temperature.at-2m', // attribute of the dataSource to be used externally
51
- styleName: 'base', // The name of the style (from styles.json) to apply for the layer
52
- },
53
- // Lazy setup
54
- // 'true': perform setup and data loading on 'addTo(map)'.
55
- // 'false': start loading immediately, but loading is not finished when layer is created.
56
- // the signal 'setupcomplete' is fired when loading is finished.
57
- // useful when a big bunch of layers is used, so layers are not wasting memory and bandwidth.
58
- lazy: true,
59
- options: {
60
- opacity: 0.99,
61
- },
62
- });
63
- layerS.addTo(map);
64
-
65
- // instead of layerS.once('setupcomplete') setupCompletePromise can be used
66
- layerS.setupCompletePromise.then(() => {
67
- window.alert('"promise" setup complete');
68
- });
69
- </script>
70
- </body>
71
- </html>
@@ -1,64 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>WxTiles v2.0</title>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <link rel="shortcut icon" href="res/icon.png" type="image/x-icon" />
8
-
9
- <!-- LEAFLET lib goes first -->
10
- <link
11
- rel="stylesheet"
12
- href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
13
- integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
14
- crossorigin=""
15
- />
16
-
17
- <script
18
- src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
19
- integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
20
- crossorigin=""
21
- ></script>
22
-
23
- <!-- WxTile lib goes here -->
24
- <script src="../dist/web/wxtile.js"></script>
25
- <link rel="stylesheet" href="../dist/web/wxtile.css" />
26
- </head>
27
-
28
- <body style="margin: 0">
29
- <div id="map" style="height: 100vh; width: 100vw"></div>
30
-
31
- <script>
32
- ('use strict');
33
- const { WxTileLogging, WxTileLibSetup, WxTileWatermark, WxTileLayer, WxGetColorStyles } = window.wxtilejs;
34
-
35
- // Leaflet basic setup // set the main Leaflet's map object, compose and add base layers
36
- const map = L.map('map', { center: [-37.803113, 174.878166], zoom: 5, zoomControl: false });
37
-
38
- WxTileLogging(true); // use wxtiles logging -> console.log
39
- WxTileWatermark({ URI: 'res/wxtiles-logo.png', position: 'topleft' }).addTo(map); // set the correct URI
40
- // ESSENTIAL step to get lib ready.
41
- WxTileLibSetup(); // if empty defaults are used
42
-
43
- // VECTOR field setup
44
- const layerV = WxTileLayer({
45
- dataSource: {
46
- serverURI: 'https://tiles.metoceanapi.com/data', // server to fetch data from
47
- ext: 'png', // png / webp (default) - wxtilesplitter output format
48
- dataset: 'ecwmf.global', // dataset of the dataset
49
- variables: ['wind.speed.eastward.at-10m', 'wind.speed.northward.at-10m'], // variabls to be used for the layer rendering
50
- name: 'wind speed at 10m', // attribute of the dataSource to be used externally
51
- styleName: 'base', // The name of the style (from styles.json) to apply for the layer
52
- },
53
- // Lazy setup
54
- // 'true': perform setup and data loading on 'addTo(map)'.
55
- // 'false': start loading immediately, but loading is not finished when layer is created.
56
- // the signal 'setupcomplete' is fired when loading is finished.
57
- // useful when a big bunch of layers is used, so layers are not wasting memory and bandwidth.
58
- lazy: false,
59
- options: { opacity: 0.99 },
60
- });
61
- layerV.addTo(map);
62
- </script>
63
- </body>
64
- </html>
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "include": ["src"],
3
- "compilerOptions": {
4
- "outDir": "dist/es",
5
- "allowSyntheticDefaultImports": true,
6
- "moduleResolution": "node",
7
- "declaration": true,
8
- "noImplicitThis": true,
9
- "emitDeclarationOnly": true,
10
- "noImplicitReturns": true,
11
- "strictNullChecks": true,
12
- "strictFunctionTypes": true,
13
- "strictPropertyInitialization": true,
14
- "lib": ["es2015", "dom"],
15
- "allowJs": true,
16
- "sourceMap": true,
17
- "resolveJsonModule": true
18
- }
19
- }
package/watch-public.js DELETED
@@ -1,52 +0,0 @@
1
- const esbuild = require('esbuild');
2
- const express = require('express');
3
-
4
- // let watchResponse;
5
- // const disableHotReload = process.env.DISABLE_HOT_RELOAD === 'true';
6
-
7
- esbuild
8
- .build({
9
- entryPoints: ['src/index.ts'],
10
- bundle: true,
11
- // plugins: [sassPlugin()],
12
- loader: {
13
- '.ttf': 'base64',
14
- '.woff': 'base64',
15
- },
16
- target: 'es2015',
17
- format: 'iife',
18
- outfile: 'public/wxtile/wxtile.js',
19
- globalName: 'wxtilejs',
20
- sourcemap: true,
21
- minify: false,
22
- watch: {
23
- onRebuild(error, result) {
24
- if (error) {
25
- console.error('watch build failed:', error);
26
- } else {
27
- console.log('rebuilded', new Date());
28
- // !disableHotReload && watchResponse && watchResponse.write('data: refresh\n\n');
29
- }
30
- },
31
- },
32
- })
33
- .then((result) => {
34
- const app = express();
35
- app.use(express.static('public'));
36
-
37
- const PORT = 3001;
38
-
39
- app.get('/watch', function (req, res) {
40
- res.writeHead(200, {
41
- 'Content-Type': 'text/event-stream',
42
- 'Cache-Control': 'no-cache',
43
- Connection: 'keep-alive',
44
- });
45
- });
46
-
47
- const url = `http://localhost:${PORT}`;
48
- app.listen(PORT, () => {
49
- console.log(`Dev is running at ${url}`);
50
- });
51
- })
52
- .catch((e) => console.error(e.message));