You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
809 B
32 lines
809 B
const express = require("express");
|
|
const expressWs = require("express-ws");
|
|
const cors = require('cors');
|
|
|
|
const SQLite3Repository = require("./repositories/sqlite3");
|
|
|
|
const repo = new SQLite3Repository("stuff.db");
|
|
|
|
repo.setup().catch(err => {
|
|
console.error("Failed to setup db:", err);
|
|
process.exit(1);
|
|
}).then(() => {
|
|
console.log("Datbase setup complete.")
|
|
});
|
|
|
|
const app = express();
|
|
expressWs(app);
|
|
|
|
app.use(cors());
|
|
|
|
app.use(express.json({strict: false}));
|
|
|
|
app.use("/api/bike/", require("./api/bike")(repo));
|
|
app.use("/api/program/", require("./api/program")(repo));
|
|
app.use("/api/workout/", require("./api/workout")(repo));
|
|
|
|
const port = process.env.PORT || 8780;
|
|
const host = process.env.HOST || "0.0.0.0";
|
|
app.listen(port, host, () => {
|
|
console.log(`Listening on ${host}:${port}...`)
|
|
});
|
|
|