2023-03-28 01:27:25 +02:00
|
|
|
require("dotenv").config();
|
|
|
|
const express = require("express");
|
|
|
|
const cors = require("cors");
|
2020-07-22 07:36:06 +02:00
|
|
|
const app = express();
|
2017-02-18 19:57:45 +01:00
|
|
|
|
2020-07-22 07:36:06 +02:00
|
|
|
// Basic Configuration
|
|
|
|
const port = process.env.PORT || 3000;
|
2017-02-18 19:57:45 +01:00
|
|
|
|
|
|
|
app.use(cors());
|
|
|
|
|
2023-03-28 01:27:25 +02:00
|
|
|
app.use("/public", express.static(`${process.cwd()}/public`));
|
2017-02-18 19:57:45 +01:00
|
|
|
|
2023-03-28 01:27:25 +02:00
|
|
|
app.get("/", function (req, res) {
|
|
|
|
res.sendFile(process.cwd() + "/views/index.html");
|
2017-02-18 19:57:45 +01:00
|
|
|
});
|
|
|
|
|
2020-07-22 07:36:06 +02:00
|
|
|
// Your first API endpoint
|
2023-03-28 01:27:25 +02:00
|
|
|
app.get("/api/hello", function (req, res) {
|
|
|
|
res.json({ greeting: "hello API" });
|
2017-02-18 19:57:45 +01:00
|
|
|
});
|
|
|
|
|
2023-03-28 01:27:25 +02:00
|
|
|
app.listen(port, function () {
|
2020-07-22 07:36:06 +02:00
|
|
|
console.log(`Listening on port ${port}`);
|
|
|
|
});
|