mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
chore: Fix some backend router eslint issues
/puter/packages/backend/src/routers/auth/list-permissions.js 36:15 error 'APIError' is not defined no-undef /puter/packages/backend/src/routers/auth/list-sessions.js 17:15 error 'APIError' is not defined no-undef /puter/packages/backend/src/routers/auth/revoke-user-app.js 34:15 error 'APIError' is not defined no-undef 43:15 error 'APIError' is not defined no-undef /puter/packages/backend/src/routers/delete-site.js 43:11 error Unexpected empty object pattern no-empty-pattern /puter/packages/backend/src/routers/drivers/usage.js 146:11 error 'k' is not defined no-undef 147:21 error 'k' is not defined no-undef 147:52 error 'k' is not defined no-undef /puter/packages/backend/src/routers/drivers/xd.js 68:5 error 'window' is not defined no-undef 69:21 error Parsing error: The keyword 'interface' is reserved /puter/packages/backend/src/routers/filesystem_api/batch/all.js 51:21 error 'get_app' is not defined no-undef 224:13 error Unexpected constant condition no-constant-condition /puter/packages/backend/src/routers/filesystem_api/copy.js 70:10 error Unexpected constant condition no-constant-condition 106:13 error Duplicate key 'new_name' no-dupe-keys /puter/packages/backend/src/routers/filesystem_api/read.js 80:5 error Unreachable code no-unreachable /puter/packages/backend/src/routers/filesystem_api/token-read.js 53:9 error Unreachable code no-unreachable 58:9 error Unreachable code no-unreachable 104:5 error Unreachable code no-unreachable /puter/packages/backend/src/routers/hosting/puter-site.js 65:21 error Unexpected constant nullishness on the left-hand side of a `??` expression no-constant-binary-expression
This commit is contained in:
parent
b4af28a91b
commit
0c0846eef9
@ -21,6 +21,7 @@ const { get_app, get_user } = require("../../helpers");
|
|||||||
const { UserActorType } = require("../../services/auth/Actor");
|
const { UserActorType } = require("../../services/auth/Actor");
|
||||||
const { DB_READ } = require("../../services/database/consts");
|
const { DB_READ } = require("../../services/database/consts");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
|
const { APIError } = require('../../api/APIError');
|
||||||
|
|
||||||
module.exports = eggspress('/auth/list-permissions', {
|
module.exports = eggspress('/auth/list-permissions', {
|
||||||
subdomain: 'api',
|
subdomain: 'api',
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const eggspress = require("../../api/eggspress");
|
const eggspress = require("../../api/eggspress");
|
||||||
const { UserActorType } = require("../../services/auth/Actor");
|
const { UserActorType } = require("../../services/auth/Actor");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
|
const { APIError } = require('../../api/APIError');
|
||||||
|
|
||||||
module.exports = eggspress('/auth/list-sessions', {
|
module.exports = eggspress('/auth/list-sessions', {
|
||||||
subdomain: 'api',
|
subdomain: 'api',
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
const eggspress = require("../../api/eggspress");
|
const eggspress = require("../../api/eggspress");
|
||||||
const { UserActorType } = require("../../services/auth/Actor");
|
const { UserActorType } = require("../../services/auth/Actor");
|
||||||
const { Context } = require("../../util/context");
|
const { Context } = require("../../util/context");
|
||||||
|
const { APIError } = require('../../api/APIError');
|
||||||
|
|
||||||
module.exports = eggspress('/auth/revoke-user-app', {
|
module.exports = eggspress('/auth/revoke-user-app', {
|
||||||
subdomain: 'api',
|
subdomain: 'api',
|
||||||
|
@ -40,7 +40,6 @@ router.post('/delete-site', auth, express.json(), async (req, res, next)=>{
|
|||||||
return res.status(400).send('site_uuid is required')
|
return res.status(400).send('site_uuid is required')
|
||||||
|
|
||||||
// modules
|
// modules
|
||||||
const {} = require('../helpers');
|
|
||||||
const db = req.services.get('database').get(DB_WRITE, 'subdomains:legacy');
|
const db = req.services.get('database').get(DB_WRITE, 'subdomains:legacy');
|
||||||
|
|
||||||
await db.write(
|
await db.write(
|
||||||
|
@ -143,7 +143,7 @@ module.exports = eggspress('/drivers/usage', {
|
|||||||
// usages.apps.push(usage);
|
// usages.apps.push(usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( k in usages.apps ) {
|
for ( const k in usages.apps ) {
|
||||||
usages.apps[k] = Object.values(usages.apps[k]);
|
usages.apps[k] = Object.values(usages.apps[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,9 @@ const script = async function script () {
|
|||||||
return await response.json();
|
return await response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* global window */
|
||||||
window.addEventListener('message', async event => {
|
window.addEventListener('message', async event => {
|
||||||
const { id, interface, method, params } = event.data;
|
const { id, interface: interface_, method, params } = event.data;
|
||||||
let has_file = false;
|
let has_file = false;
|
||||||
for ( const k in params ) {
|
for ( const k in params ) {
|
||||||
if ( params[k] instanceof File ) {
|
if ( params[k] instanceof File ) {
|
||||||
@ -75,11 +76,11 @@ const script = async function script () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result = has_file ? await fcall({
|
const result = has_file ? await fcall({
|
||||||
interface_name: interface,
|
interface_name: interface_,
|
||||||
method_name: method,
|
method_name: method,
|
||||||
params,
|
params,
|
||||||
}) : await call({
|
}) : await call({
|
||||||
interface_name: interface,
|
interface_name: interface_,
|
||||||
method_name: method,
|
method_name: method,
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,7 @@ const Busboy = require('busboy');
|
|||||||
const { BatchExecutor } = require("../../../filesystem/batch/BatchExecutor");
|
const { BatchExecutor } = require("../../../filesystem/batch/BatchExecutor");
|
||||||
const { TeePromise } = require("../../../util/promise");
|
const { TeePromise } = require("../../../util/promise");
|
||||||
const { EWMA, MovingMode } = require("../../../util/opmath");
|
const { EWMA, MovingMode } = require("../../../util/opmath");
|
||||||
|
const { get_app } = require('../../../helpers');
|
||||||
|
|
||||||
const commands = require('../../../filesystem/batch/commands.js').commands;
|
const commands = require('../../../filesystem/batch/commands.js').commands;
|
||||||
|
|
||||||
@ -221,28 +222,6 @@ module.exports = eggspress('/batch', {
|
|||||||
let ps = [];
|
let ps = [];
|
||||||
|
|
||||||
busboy.on('file', async (fieldname, stream, detais) => {
|
busboy.on('file', async (fieldname, stream, detais) => {
|
||||||
if (false) {
|
|
||||||
ended[i] = false;
|
|
||||||
ps[i] = new TeePromise();
|
|
||||||
const this_i = i;
|
|
||||||
stream.on('end', () => {
|
|
||||||
ps[this_i].resolve();
|
|
||||||
ended[this_i] = true;
|
|
||||||
batch_widget.ec++;
|
|
||||||
});
|
|
||||||
if ( i > 0 ) {
|
|
||||||
if ( ! ended[i-1] ) {
|
|
||||||
batch_widget.sc++;
|
|
||||||
// stream.pause();
|
|
||||||
batch_widget.wc++;
|
|
||||||
await Promise.all(Array(i).fill(0).map((_, j) => ps[j]));
|
|
||||||
batch_widget.wc--;
|
|
||||||
// stream.resume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( batch_exe.total_tbd ) {
|
if ( batch_exe.total_tbd ) {
|
||||||
batch_exe.total_tbd = false;
|
batch_exe.total_tbd = false;
|
||||||
batch_widget.ic = pending_operations.length;
|
batch_widget.ic = pending_operations.length;
|
||||||
|
@ -66,18 +66,6 @@ module.exports = eggspress('/copy', {
|
|||||||
x.set(operationTraceSvc.ckey('frame'), frame);
|
x.set(operationTraceSvc.ckey('frame'), frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEMP: Testing copy with its own sql queue
|
|
||||||
if ( false ) {
|
|
||||||
const x = Context.get();
|
|
||||||
const svc = new ProxyContainer(x.get('services'));
|
|
||||||
const s = new DatabaseFSEntryService({
|
|
||||||
services: x.get('services'),
|
|
||||||
label: 'Copy-DatabaseFSEntryService',
|
|
||||||
});
|
|
||||||
svc.set('systemFSEntryService', s);
|
|
||||||
x.set('services', svc);
|
|
||||||
}
|
|
||||||
|
|
||||||
const log = req.services.get('log-service').create('copy');
|
const log = req.services.get('log-service').create('copy');
|
||||||
const filesystem = req.services.get('filesystem');
|
const filesystem = req.services.get('filesystem');
|
||||||
|
|
||||||
@ -103,7 +91,6 @@ module.exports = eggspress('/copy', {
|
|||||||
source: req.values.source,
|
source: req.values.source,
|
||||||
new_name: req.body.new_name,
|
new_name: req.body.new_name,
|
||||||
|
|
||||||
new_name: req.body.new_name,
|
|
||||||
overwrite: req.body.overwrite ?? false,
|
overwrite: req.body.overwrite ?? false,
|
||||||
dedupe_name,
|
dedupe_name,
|
||||||
|
|
||||||
|
@ -74,15 +74,4 @@ module.exports = eggspress('/read', {
|
|||||||
res.set('Content-Type', 'application/octet-stream');
|
res.set('Content-Type', 'application/octet-stream');
|
||||||
|
|
||||||
stream.pipe(res);
|
stream.pipe(res);
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
const filesystem = req.services.get('filesystem');
|
|
||||||
await filesystem.read(req.fs, res, {
|
|
||||||
...req.values,
|
|
||||||
user: req.user,
|
|
||||||
version_id: req.query.version_id,
|
|
||||||
line_count,
|
|
||||||
byte_count,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -49,12 +49,10 @@ module.exports = eggspress('/token-read', {
|
|||||||
const actor = await svc_auth.authenticate_from_token(access_jwt);
|
const actor = await svc_auth.authenticate_from_token(access_jwt);
|
||||||
|
|
||||||
if ( ! actor ) {
|
if ( ! actor ) {
|
||||||
throw new Error('A');
|
|
||||||
throw APIError.create('token_auth_failed');
|
throw APIError.create('token_auth_failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! (actor.type instanceof AccessTokenActorType) ) {
|
if ( ! (actor.type instanceof AccessTokenActorType) ) {
|
||||||
throw new Error('B');
|
|
||||||
throw APIError.create('token_auth_failed');
|
throw APIError.create('token_auth_failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,16 +96,5 @@ module.exports = eggspress('/token-read', {
|
|||||||
res.setHeader('Content-Type', mime_type);
|
res.setHeader('Content-Type', mime_type);
|
||||||
|
|
||||||
stream.pipe(res);
|
stream.pipe(res);
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
const filesystem = req.services.get('filesystem');
|
|
||||||
await filesystem.read(req.fs, res, {
|
|
||||||
...req.values,
|
|
||||||
user: req.user,
|
|
||||||
version_id: req.query.version_id,
|
|
||||||
line_count,
|
|
||||||
byte_count,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class PuterSiteMiddleware extends AdvancedBase {
|
|||||||
req.subdomains[0] === 'devtest' ? 'devtest' :
|
req.subdomains[0] === 'devtest' ? 'devtest' :
|
||||||
req.hostname.slice(0, -1 * (config.static_hosting_domain.length + 1));
|
req.hostname.slice(0, -1 * (config.static_hosting_domain.length + 1));
|
||||||
|
|
||||||
let path = (req.baseUrl + req.path) ?? 'index.html';
|
let path = (req.baseUrl + req.path) || 'index.html';
|
||||||
|
|
||||||
const context = Context.get();
|
const context = Context.get();
|
||||||
const services = context.get('services');
|
const services = context.get('services');
|
||||||
|
Loading…
Reference in New Issue
Block a user