-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (30 loc) · 999 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
const express = require('express');
const app = express();
const cors = require('cors');
const BFS_Service = require('./services/bfs-service').BFS_Service;
const ASTAR_Service = require('./services/astar-service').ASTAR_Service;
const IDDFS_Service = require('./services/iddfs-service').IDDFS_Service;
app.use(cors({
origin: 'http://localhost:3000'
}));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.post('/bfs', (req, res) => {
console.log(req.body);
const bfs_service = new BFS_Service();
start = req.body.start;
res.json(bfs_service.start(start));
});
app.post('/astar', (req, res) => {
console.log(req.body);
const astar_service = new ASTAR_Service();
start = req.body.start;
res.json(astar_service.start(start));
});
app.post('/iddfs', (req, res) => {
console.log(req.body);
const iddfs_service = new IDDFS_Service();
start = req.body.start;
res.json(iddfs_service.start(start));
});
app.listen(4000);