merge appdb.js into apps.js

This commit is contained in:
Girish Ramakrishnan
2021-08-20 09:19:44 -07:00
parent b6f2d6d620
commit 77f5cb183b
39 changed files with 1599 additions and 2495 deletions

View File

@@ -5,7 +5,7 @@ exports = module.exports = {
stop
};
var apps = require('./apps.js'),
const apps = require('./apps.js'),
assert = require('assert'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
@@ -20,25 +20,24 @@ var apps = require('./apps.js'),
safe = require('safetydance'),
_ = require('underscore');
var gHttpServer = null;
let gHttpServer = null;
function authorizeApp(req, res, next) {
async function authorizeApp(req, res, next) {
// make the tests pass for now
if (constants.TEST) {
req.app = { id: 'testappid' };
return next();
}
apps.getByIpAddress(req.connection.remoteAddress, function (error, app) {
if (error && error.reason === BoxError.NOT_FOUND) return next(new HttpError(401, 'Unauthorized'));
if (error) return next(new HttpError(500, error));
const [error, app] = await apps.getByIpAddress(req.connection.remoteAddress);
if (error) return next(new HttpError(500, error));
if (!app) return next(new HttpError(401, 'Unauthorized'));
if (!('docker' in app.manifest.addons)) return next(new HttpError(401, 'Unauthorized'));
if (!('docker' in app.manifest.addons)) return next(new HttpError(401, 'Unauthorized'));
req.app = app;
req.app = app;
next();
});
next();
}
function attachDockerRequest(req, res, next) {