-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (33 loc) · 933 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
41
42
import express, { json } from 'express';
const app = express();
import { config } from 'dotenv';
import mongoose from 'mongoose';
import cors from 'cors';
import Govee from "node-govee-led";
import client from "./Client.js";
config();
const GoveeClient = new Govee({
apiKey: process.env.API,
mac: "",
model: ""
})
GoveeClient.getDevices().then(data => console.log(data))
client.init();
client.govee.turnOff();
// Import routes
import authRoute from './routes/auth.js';
import controlRoute from './routes/controler.js';
// Connect to DB
mongoose.connect(process.env.DB_CONNECT, () => {
console.log('Connected to database!');
})
// Middleware
app.use(json());
app.use(cors());
// Routes Middleware
app.use('/api/user', authRoute);
app.use('/api/control', controlRoute);
const port = process.env.port ? process.env.port : 3000
app.listen(port, () => {
console.log(`Successfuly started lisening on port ${port}`)
})