-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
130 lines (116 loc) · 4.12 KB
/
build.js
File metadata and controls
130 lines (116 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env node
import { writeFileSync, mkdirSync, readFileSync, existsSync } from 'fs';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
// Create public directory structure
const publicDir = `${__dirname}/public`;
try {
mkdirSync(publicDir, { recursive: true });
} catch {
// Directory might already exist
}
// Read existing index.html or create a default one
const indexHtmlPath = `${publicDir}/index.html`;
let indexHTML;
if (existsSync(indexHtmlPath)) {
// Read the existing index.html file
indexHTML = readFileSync(indexHtmlPath, 'utf8');
console.log('📖 Reading existing public/index.html');
} else {
// Create default index.html if it doesn't exist
indexHTML = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SugarSugar API</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
line-height: 1.6;
background: #f8f9fa;
}
.container {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 { color: #333; border-bottom: 3px solid #007acc; padding-bottom: 10px; }
h2 { color: #555; margin-top: 30px; }
.endpoint {
background: #f1f3f4;
padding: 15px;
border-radius: 5px;
margin: 10px 0;
border-left: 4px solid #007acc;
}
.endpoint code {
background: #e8f4f8;
padding: 2px 6px;
border-radius: 3px;
font-family: 'Monaco', 'Consolas', monospace;
}
a { color: #007acc; text-decoration: none; }
a:hover { text-decoration: underline; }
.status {
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
font-size: 0.9em;
font-weight: bold;
}
.status.live { background: #d4edda; color: #155724; }
.footer {
margin-top: 40px;
padding-top: 20px;
border-top: 1px solid #eee;
text-align: center;
color: #666;
}
</style>
</head>
<body>
<div class="container">
<h1>🍭 SugarSugar API</h1>
<p><strong>A webservice to ask Dexcom Share servers for blood glucose data</strong></p>
<p><span class="status live">LIVE</span> API Version 1.0.0</p>
<h2>📊 Available Endpoints</h2>
<div class="endpoint">
<strong>GET <code>/api/health</code></strong><br>
Service health check and status
</div>
<div class="endpoint">
<strong>GET <code>/api/glucose</code></strong><br>
Latest glucose reading with simple format
</div>
<h2>🧪 Test the API</h2>
<p>Try these endpoints:</p>
<ul>
<li><a href="/api/health" target="_blank">Health Check</a></li>
<li><a href="/api/glucose" target="_blank">Latest Glucose</a></li>
</ul>
<h2>📖 Documentation</h2>
<p>For complete setup instructions and API documentation, visit the
<a href="https://github.com/run-time/sugarsugar" target="_blank">GitHub repository</a>.</p>
<div class="footer">
<p>Made with ❤️ by Dave Alger | Powered by Dexcom Share API</p>
<p><small>This project is not affiliated with Dexcom, Inc.</small></p>
</div>
</div>
</body>
</html>`;
console.log('🆕 Created default public/index.html');
}
// The file is now read from disk, so we don't need to write it again
// unless we're creating a default one
if (!existsSync(indexHtmlPath)) {
writeFileSync(indexHtmlPath, indexHTML);
}
console.log('✅ Build process completed');
console.log('📁 Using: public/index.html');
console.log('\n\n\x1b[32m🚀 Ready for Vercel deployment!\x1b[0m\n\n');