Files: 523c133eb74777d899a46f3566f6654c5a92a360 / nodejs-assets / nodejs-project / gateway.js
597 bytesRaw
1 | const DatGateway = require('dat-gateway'); |
2 | |
3 | /** |
4 | * @function default |
5 | * @param {Number} port Port to start the gateway |
6 | * @param {String} appPath Path to use as a directory to Dats |
7 | * @return {Promise} Resolves when the server is started |
8 | */ |
9 | module.exports = (port, appPath) => |
10 | new Promise((resolve, reject) => { |
11 | const gateway = new DatGateway({ |
12 | dir: appPath, |
13 | max: 20, |
14 | maxAge: 10 * 60 * 1000 // Ten minutes |
15 | }); |
16 | |
17 | gateway |
18 | .listen(port) |
19 | .then(() => { |
20 | return resolve(); |
21 | }) |
22 | .catch(err => { |
23 | return reject(err); |
24 | }); |
25 | }); |
Built with git-ssb-web