Added node workspace.

This commit is contained in:
SamTV12345 2024-03-15 20:59:28 +01:00
parent 95d99424e1
commit 65046a3ff2
11 changed files with 29 additions and 27 deletions

View file

@ -2,6 +2,7 @@
/* /*
* This is a debug tool. It checks all revisions for data corruption * This is a debug tool. It checks all revisions for data corruption
*/ */
import process from "node:process";
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.

View file

@ -2,6 +2,7 @@
/* /*
* This is a debug tool. It checks all revisions for data corruption * This is a debug tool. It checks all revisions for data corruption
*/ */
import process from "node:process";
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.

View file

@ -7,11 +7,11 @@
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.
import fs from "fs"; import fs from "node:fs";
import path from "path"; import path from "node:path";
import querystring from "querystring"; import querystring from "node:querystring";
import axios from 'axios' import axios from 'axios'

View file

@ -5,10 +5,10 @@
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.
import path from "path"; import path from "node:path";
import fs from "fs"; import fs from "node:fs";
import process from "process"; import process from "node:process";
process.on('unhandledRejection', (err) => { throw err; }); process.on('unhandledRejection', (err) => { throw err; });
import axios from 'axios' import axios from 'axios'

View file

@ -7,10 +7,10 @@
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.
import path from "path"; import path from "node:path";
import fs from "fs"; import fs from "node:fs";
import process from "process"; import process from "node:process";
import axios from "axios"; import axios from "axios";
process.on('unhandledRejection', (err) => { throw err; }); process.on('unhandledRejection', (err) => { throw err; });

View file

@ -8,9 +8,8 @@
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.
import util from "util"; import util from "node:util";
import process from "process"; import process from "node:process";
import dirtyDB from "ueberdb2";
process.on('unhandledRejection', (err) => { throw err; }); process.on('unhandledRejection', (err) => { throw err; });
if (process.argv.length !== 3) throw new Error('Use: node extractPadData.js $PADID'); if (process.argv.length !== 3) throw new Error('Use: node extractPadData.js $PADID');
@ -40,7 +39,7 @@ const padId = process.argv[2];
const pad = await padManager.getPad(padId); const pad = await padManager.getPad(padId);
// add all authors // add all authors
neededDBValues.push(...pad.getAllAuthors().map((author) => `globalAuthor:${author}`)); neededDBValues.push(...pad.getAllAuthors().map((author: string) => `globalAuthor:${author}`));
// add all revisions // add all revisions
for (let rev = 0; rev <= pad.head; ++rev) { for (let rev = 0; rev <= pad.head; ++rev) {

View file

@ -2,7 +2,7 @@
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.
import util from "util"; import util from "node:util";
const fs = require('fs'); const fs = require('fs');
import log4js from 'log4js'; import log4js from 'log4js';
import readline from 'readline'; import readline from 'readline';

View file

@ -10,18 +10,18 @@
* node bin/plugins/checkPlugin.js ep_whatever autopush * node bin/plugins/checkPlugin.js ep_whatever autopush
*/ */
import process from 'process'; import process from 'node:process';
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.
process.on('unhandledRejection', (err) => { throw err; }); process.on('unhandledRejection', (err) => { throw err; });
import {strict as assert} from 'assert'; import {strict as assert} from 'assert';
import fs from 'fs'; import fs from 'node:fs';
const fsp = fs.promises; const fsp = fs.promises;
import childProcess from 'child_process'; import childProcess from 'node:child_process';
import log4js from 'log4js'; import log4js from 'log4js';
import path from 'path'; import path from 'node:path';
const logger = log4js.getLogger('checkPlugin'); const logger = log4js.getLogger('checkPlugin');

View file

@ -4,12 +4,12 @@
// unhandled rejection into an uncaught exception, which does cause Node.js to exit. // unhandled rejection into an uncaught exception, which does cause Node.js to exit.
process.on('unhandledRejection', (err) => { throw err; }); process.on('unhandledRejection', (err) => { throw err; });
import fs from 'fs'; import fs from 'node:fs';
import childProcess from 'child_process'; import childProcess from 'node:child_process';
import log4js from 'log4js'; import log4js from 'log4js';
import path from 'path'; import path from 'node:path';
import semver from 'semver'; import semver from 'semver';
import {exec} from 'child_process'; import {exec} from 'node:child_process';
log4js.configure({appenders: {console: {type: 'console'}}, log4js.configure({appenders: {console: {type: 'console'}},
categories: { categories: {

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import process from "process"; import process from "node:process";
/* /*
* This is a repair tool. It extracts all datas of a pad, removes and inserts them again. * This is a repair tool. It extracts all datas of a pad, removes and inserts them again.

View file

@ -23,13 +23,14 @@ const connect = (etherpadBaseUrl, namespace = '/', options = {}) => {
let socketOptions = { let socketOptions = {
path: socketioUrl.pathname, path: socketioUrl.pathname,
upgrade: true, upgrade: true,
transports: ["websocket"] transports: ['websocket'],
} };
socketOptions = Object.assign(options, socketOptions); socketOptions = Object.assign(options, socketOptions);
const socket = io(namespaceUrl.href, socketOptions); const socket = io(namespaceUrl.href, socketOptions);
socket.on('connect_error', (error) => { socket.on('connect_error', (error) => {
console.log('Error connecting to pad', error);
if (socket.io.engine.transports.indexOf('polling') === -1) { if (socket.io.engine.transports.indexOf('polling') === -1) {
console.warn('WebSocket connection failed. Falling back to long-polling.'); console.warn('WebSocket connection failed. Falling back to long-polling.');
socket.io.opts.transports = ['polling']; socket.io.opts.transports = ['polling'];