-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.ts
52 lines (41 loc) · 1.26 KB
/
server.ts
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
45
46
47
48
49
50
51
52
const express = require("express");
import { createFromSnapshots, createSnapshots } from "./src/index";
const app = express()
const port = 3000;
let snapshotsData = createSnapshots({
vertexCount: 10,
snapshotCount: 200,
});
app.use(express.json({ limit: '50mb' }))
app.get('/snapshots', (req: any, res: any) => {
const { snapshots, details } = snapshotsData;
res.json({ snapshots, details });
})
app.get('/snapshots-string', (req: any, res: any) => {
res.json(snapshotsData.snapshotStrings)
})
app.get('/snapshots-matrix', (req: any, res: any) => {
res.json(snapshotsData.snapshotMatrices)
})
app.post('/from-snapshots', (req: any, res: any) => {
const { data, name } = req.body;
const snapshotsData = createFromSnapshots(data, name);
const { snapshots, details } = snapshotsData;
res.json({ snapshots, details });
})
app.post('/snapshots', (req: any, res: any) => {
const { vertexCount, snapshotCount, probability, name } = req.body;
snapshotsData = createSnapshots({
vertexCount,
snapshotCount,
probability,
name,
});
const { snapshots, details } = snapshotsData;
res.json({ snapshots, details });
})
app.get('/')
app.use(express.static('client'))
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})