-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (35 loc) · 1.17 KB
/
index.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
43
44
import express from "express";
import cors from "cors";
const app = express();
import dbConnect from "./dbconnection.js";
import routes from "./routes/routes.js"
// import userRoutes from "./unused/userRoutes.js";
import path from "path";
// import clientAPI from "./api/send_sms.js";
const port = process.env.PORT || 8000;
dbConnect();
app.use(cors());
app.use('/images', express.static('images'));
app.use(express.json());
// app.use('/', userRoutes);
app.use('/api/market', routes);
// used for testing static json files
app.get('/testproduct', (req, res) => {
res.header("Content-Type",'application/json');
res.sendFile(path.resolve('unused/Product.json'));
})
app.get('/testcategory', (req, res) => {
res.header("Content-Type",'application/json');
res.sendFile(path.resolve('unused/BrowseCate.json'));
})
app.get('/testdetails', (req, res) => {
res.header("Content-Type",'application/json');
res.sendFile(path.resolve('unused/Details.json'));
})
// send sms
// app.use('/sms', clientAPI);
// wildcard 404
app.use("*", (req, res) => res.status(404).send('<h1>Sorry, page not found!</h1>'));
app.listen(port, () => {
console.log(`listening on ${port}`);
})