-
Notifications
You must be signed in to change notification settings - Fork 10
/
server.js
35 lines (28 loc) · 906 Bytes
/
server.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
import express from "express";
import getListings from "./get-listings.js"
import path from "path";
import cors from "cors";
const app = express();
app.use(cors({ origin: "https://www.bing.com" }));
app.get("/get-listings", (req, res) => {
const city = req.query.city;
const bedrooms = parseInt(req.query.bedrooms);
const bathrooms = parseInt(req.query.bathrooms);
const amenities = req.query.amenities;
try {
const listings = getListings(city, bedrooms, bathrooms, amenities);
res.send(listings);
} catch (e) {
res.status(400).send({ error: e.message });
}
});
app.get("/openapi.yaml", (req, res) => {
res.sendFile(path.resolve() + "/openapi.yaml");
});
app.get("/.well-known/ai-plugin.json", (req, res) => {
res.sendFile(path.resolve() + "/ai-plugin.json");
});
app.get("/logo.png", (req, res) => {
res.sendFile(path.resolve() + "/logo.png");
});
app.listen(8080);