-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (25 loc) · 1013 Bytes
/
server.js
File metadata and controls
33 lines (25 loc) · 1013 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
28
29
30
31
32
33
const express = require('express');
const app = express();
const port = 2019;
const mkdirp = require('mkdirp');
const bodyParser = require('body-parser');
const cors = require('cors');
// first attempt to make ./resources/ directory to store all the files
try {
mkdirp.sync("./resources");
mkdirp.sync("./resources/capsules");
mkdirp.sync("./resources/ciphertexts");
mkdirp.sync("./resources/kfrags");
mkdirp.sync("./temp"); // place to temporarily hold all uploads: if the uploaded file has a hash matching that declared in the blockchain, it will be copied t the resources folder
} catch (e) {
throw e;
}
const apiRouter = require("./routes/api");
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cors());
// parse application/json
app.use(bodyParser.json())
app.use("/api", apiRouter);
app.listen(port, () => console.log(`Hypervault ResourceServer listening on port ${port}!`));
module.exports = app; // for Mocha testing purposes only