-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (22 loc) · 676 Bytes
/
Copy pathindex.js
File metadata and controls
27 lines (22 loc) · 676 Bytes
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
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const app = express();
const port = process.env.SERVER_PORT || 5001;
const service = require('./Service.js');
const instance = new service();
app.use(express.json());
app.use(cors({
origin: process.env.CLIENT || 'http://localhost:5173'
}));
app.post('/api/search', async (req, res) => {
const { q, location } = req.body;
const result = await instance.search(q, location);
res.json(result);
});
app.listen(port, () => {
console.log(`Server is running on:${port}`);
});
app.get('/', async(req, res) => {
res.json({status: 'Server is up and running.'});
})