-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (33 loc) · 892 Bytes
/
app.js
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
import fastify from 'fastify';
import { setupRoutes } from './routes.js'
import { setupWebUI } from './web/index.js'
import { networkCron } from './network/cron.js'
import cors from '@fastify/cors'
import { taskScheduler } from './schedule/index.js'
import { temperatureCron } from './temperature/cron.js'
export const app = fastify();
import fs from 'fs';
import { startUp } from './setup/index.js'
startUp();
app.get('/', async (request, res) => {
return `Smartpingu Embedded API`;
});
app.get('/reset', async (req, res) => {
fs.copyFileSync("example.manifest.json", "manifest.json");
})
app.register(cors, {
origin: '*'
})
setupRoutes();
setupWebUI();
taskScheduler();
app.listen({
host: '0.0.0.0',
port: 3000,
}, (err, address) => {
if (err) {
console.error(err);
process.exit(1);
}
console.log(`Server listening on ${address}`);
});