mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 00:23:03 +00:00
feat: migrate to esm
This commit is contained in:
@@ -21,8 +21,8 @@ import {
|
||||
SCThings,
|
||||
SCThingType,
|
||||
} from '@openstapps/core';
|
||||
import {Client} from './client';
|
||||
import {BulkWithMultipleTypesError} from './errors';
|
||||
import {Client} from './client.js';
|
||||
import {BulkWithMultipleTypesError} from './errors.js';
|
||||
|
||||
/**
|
||||
* A bulk
|
||||
|
||||
@@ -19,10 +19,10 @@ import {readFileSync} from 'fs';
|
||||
import path from 'path';
|
||||
import {URL} from 'url';
|
||||
import waitOn from 'wait-on';
|
||||
import {copy} from './copy';
|
||||
import {copy} from './copy.js';
|
||||
// eslint-disable-next-line unicorn/prevent-abbreviations
|
||||
import {e2eRun} from './e2e';
|
||||
import {HttpClient} from './http-client';
|
||||
import {e2eRun} from './e2e.js';
|
||||
import {HttpClient} from './http-client.js';
|
||||
|
||||
process.on('unhandledRejection', async error => {
|
||||
await Logger.error('unhandledRejection', error);
|
||||
|
||||
@@ -31,8 +31,8 @@ import {
|
||||
SCSearchRoute,
|
||||
SCThings,
|
||||
} from '@openstapps/core';
|
||||
import {ApiError, CoreVersionIncompatibleError, OutOfRangeError, PluginNotAvailableError} from './errors';
|
||||
import {HttpClientHeaders, HttpClientInterface} from './http-client-interface';
|
||||
import {ApiError, CoreVersionIncompatibleError, OutOfRangeError, PluginNotAvailableError} from './errors.js';
|
||||
import {HttpClientHeaders, HttpClientInterface} from './http-client-interface.js';
|
||||
|
||||
/**
|
||||
* StApps-API client
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {asyncPool} from '@krlwlfrt/async-pool/lib/async-pool';
|
||||
import {asyncPool} from '@krlwlfrt/async-pool/lib/async-pool.js';
|
||||
import {
|
||||
isThing,
|
||||
SCAssociatedThingWithoutReferences,
|
||||
@@ -28,9 +28,9 @@ import {
|
||||
import moment from 'moment';
|
||||
import clone = require('rfdc');
|
||||
import {v5} from 'uuid';
|
||||
import {Bulk} from './bulk';
|
||||
import {Client} from './client';
|
||||
import {EmptyBulkError, NamespaceNotDefinedError} from './errors';
|
||||
import {Bulk} from './bulk.js';
|
||||
import {Client} from './client.js';
|
||||
import {EmptyBulkError, NamespaceNotDefinedError} from './errors.js';
|
||||
|
||||
/**
|
||||
* StApps-API client
|
||||
@@ -187,7 +187,7 @@ export class ConnectorClient extends Client {
|
||||
*/
|
||||
async bulk<T extends SCThings>(type: SCThingType, source: string, timeout?: number): Promise<Bulk<T>> {
|
||||
// set default value for timeout to one hour
|
||||
const bulkTimeout = typeof timeout !== 'number' ? ConnectorClient.BULK_TIMEOUT : timeout;
|
||||
const bulkTimeout = typeof timeout === 'number' ? timeout : ConnectorClient.BULK_TIMEOUT;
|
||||
|
||||
const bulkData = await this.invokeRoute<SCBulkResponse>(this.bulkRoute, undefined, {
|
||||
expiration: moment().add(bulkTimeout, 'seconds').format(),
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {asyncPool} from '@krlwlfrt/async-pool/lib/async-pool';
|
||||
import {asyncPool} from '@krlwlfrt/async-pool/lib/async-pool.js';
|
||||
import {SCSearchRequest, SCThingType} from '@openstapps/core';
|
||||
import {Bar} from 'cli-progress';
|
||||
import {Client} from './client';
|
||||
import {ConnectorClient} from './connector-client';
|
||||
import {OutOfRangeError} from './errors';
|
||||
import {HttpClientInterface} from './http-client-interface';
|
||||
import {Client} from './client.js';
|
||||
import {ConnectorClient} from './connector-client.js';
|
||||
import {OutOfRangeError} from './errors.js';
|
||||
import {HttpClientInterface} from './http-client-interface.js';
|
||||
|
||||
/**
|
||||
* Options to set up copying data from one backend to another
|
||||
|
||||
@@ -20,8 +20,8 @@ import {deepStrictEqual} from 'assert';
|
||||
import {readdir, readFile} from 'fs';
|
||||
import path from 'path';
|
||||
import {promisify} from 'util';
|
||||
import {ConnectorClient} from './connector-client';
|
||||
import {HttpClientInterface} from './http-client-interface';
|
||||
import {ConnectorClient} from './connector-client.js';
|
||||
import {HttpClientInterface} from './http-client-interface.js';
|
||||
|
||||
const localItemMap: Map<string, SCThings> = new Map();
|
||||
const remoteItemMap: Map<string, SCThings> = new Map();
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCPluginRegisterRequest, SCPluginRegisterRoute} from '@openstapps/core';
|
||||
import {ConnectorClient} from './connector-client';
|
||||
import {Plugin} from './plugin';
|
||||
import {ConnectorClient} from './connector-client.js';
|
||||
import {Plugin} from './plugin.js';
|
||||
|
||||
/**
|
||||
* The PluginClient for registering and unregistering HTTP Plugins
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Converter} from '@openstapps/core-tools/lib/schema';
|
||||
import {Converter} from '@openstapps/core-tools/lib/schema.js';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import bodyParser from 'body-parser';
|
||||
import express from 'express';
|
||||
@@ -126,7 +125,7 @@ export abstract class Plugin {
|
||||
this.app.use(bodyParser.json());
|
||||
this.port = Plugin.normalizePort(
|
||||
/* istanbul ignore next */
|
||||
typeof process.env.PORT !== 'undefined' ? process.env.PORT : port.toString(),
|
||||
typeof process.env.PORT === 'undefined' ? port.toString() : process.env.PORT,
|
||||
);
|
||||
this.app.set('port', this.port);
|
||||
|
||||
@@ -175,18 +174,21 @@ export abstract class Plugin {
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
case 'EACCES': {
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
Logger.error(`${bind} requires elevated privileges`);
|
||||
process.exit(1);
|
||||
break;
|
||||
case 'EADDRINUSE':
|
||||
}
|
||||
case 'EADDRINUSE': {
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
Logger.error(`${bind} is already in use`);
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user