-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (32 loc) · 1.06 KB
/
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
const express = require("express");
const cors = require("cors");
const morgan = require("morgan");
const path = require("path");
const jobRouter = require("./routes/jobRoutes");
// const { handler } = require('./client/build/handler');
const app = express();
app.use(cors());
app.use(express.json());
// app.use(express.static(path.join(__dirname, "client", "dist")));
// // Handle all other routes with the Svelte app
// app.use(express.static(`${__dirname}/client`));
// app.get("*", (req, res) => {
// res.sendFile(path.join(__dirname, "client"));
// });
// app.get('/', (req, res) => {
// res.send('Welcome To Books API');
// });
app.use(express.static(`${__dirname}/client/build`));
if (process.env.NODE_ENV === "development") {
app.use(morgan("dev"));
}
// app.get("*", (req, res) => {
// res.sendFile(`${__dirname}/client/app.html`);
// console.log(`${__dirname}`);
// });
app.use("/api/v1/jobs", jobRouter);
// Handle client-side routing with SvelteKit
import("././client/build/handler.js").then(({ handler }) => {
app.use(handler);
});
module.exports = app;