style: remove extraneous whitespace in imports

This commit is contained in:
Anselm Stordeur
2019-01-09 14:30:44 +01:00
committed by Rainer Killinger
parent 16bbb7e9e3
commit 98f02b8830
20 changed files with 77 additions and 79 deletions

View File

@@ -13,25 +13,25 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCNotFoundErrorResponse, SCUnsupportedMediaTypeErrorResponse } from '@openstapps/core'; import {SCNotFoundErrorResponse, SCUnsupportedMediaTypeErrorResponse} from '@openstapps/core';
import { SCValidator } from '@openstapps/core-validator'; import {SCValidator} from '@openstapps/core-validator';
import * as bodyParser from 'body-parser'; import * as bodyParser from 'body-parser';
import * as config from 'config'; import * as config from 'config';
import * as cors from 'cors'; import * as cors from 'cors';
import * as express from 'express'; import * as express from 'express';
import * as morgan from 'morgan'; import * as morgan from 'morgan';
import { logger, mailer } from './common'; import {logger, mailer} from './common';
import { MailQueue } from './notification/MailQueue'; import {MailQueue} from './notification/MailQueue';
import { bulkAddRouter } from './routes/BulkAddRoute'; import {bulkAddRouter} from './routes/BulkAddRoute';
import { bulkDoneRouter } from './routes/BulkDoneRoute'; import {bulkDoneRouter} from './routes/BulkDoneRoute';
import { bulkRouter } from './routes/BulkRoute'; import {bulkRouter} from './routes/BulkRoute';
import { indexRouter } from './routes/IndexRoute'; import {indexRouter} from './routes/IndexRoute';
import { multiSearchRouter } from './routes/MultiSearchRoute'; import {multiSearchRouter} from './routes/MultiSearchRoute';
import { searchRouter } from './routes/SearchRoute'; import {searchRouter} from './routes/SearchRoute';
import { thingUpdateRouter } from './routes/ThingUpdateRoute'; import {thingUpdateRouter} from './routes/ThingUpdateRoute';
import { BulkStorage } from './storage/BulkStorage'; import {BulkStorage} from './storage/BulkStorage';
import { DatabaseConstructor } from './storage/Database'; import {DatabaseConstructor} from './storage/Database';
import { Elasticsearch } from './storage/elasticsearch/Elasticsearch'; import {Elasticsearch} from './storage/elasticsearch/Elasticsearch';
export const app = express(); export const app = express();

View File

@@ -14,8 +14,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import * as http from 'http'; import * as http from 'http';
import { app } from './app'; import {app} from './app';
import { logger } from './common'; import {logger} from './common';
/** /**
* Get port from environment and store in Express. * Get port from environment and store in Express.

View File

@@ -13,8 +13,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { Logger } from '@openstapps/logger'; import {Logger} from '@openstapps/logger';
import { BackendTransport } from './notification/BackendTransport'; import {BackendTransport} from './notification/BackendTransport';
export const mailer = BackendTransport.getTransportInstance(); export const mailer = BackendTransport.getTransportInstance();

View File

@@ -14,10 +14,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.nse along with * along with this program. If not, see <https://www.gnu.org/licenses/>.nse along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SMTP } from '@openstapps/logger/lib/SMTP'; import {SMTP} from '@openstapps/logger/lib/SMTP';
import { MailOptions } from 'nodemailer/lib/sendmail-transport'; import {MailOptions} from 'nodemailer/lib/sendmail-transport';
import * as Queue from 'promise-queue'; import * as Queue from 'promise-queue';
import { logger } from '../common'; import {logger} from '../common';
/** /**
* A queue that can send mails in serial * A queue that can send mails in serial
*/ */

View File

@@ -13,10 +13,10 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCBulkAddRequest, SCBulkAddResponse, SCBulkAddRoute, SCNotFoundErrorResponse } from '@openstapps/core'; import {SCBulkAddRequest, SCBulkAddResponse, SCBulkAddRoute, SCNotFoundErrorResponse} from '@openstapps/core';
import { logger } from '../common'; import {logger} from '../common';
import { BulkStorage } from '../storage/BulkStorage'; import {BulkStorage} from '../storage/BulkStorage';
import { createRoute } from './Route'; import {createRoute} from './Route';
const bulkRouteModel = new SCBulkAddRoute(); const bulkRouteModel = new SCBulkAddRoute();

View File

@@ -13,10 +13,10 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCBulkDoneRequest, SCBulkDoneResponse, SCBulkDoneRoute, SCNotFoundErrorResponse } from '@openstapps/core'; import {SCBulkDoneRequest, SCBulkDoneResponse, SCBulkDoneRoute, SCNotFoundErrorResponse} from '@openstapps/core';
import { logger } from '../common'; import {logger} from '../common';
import { BulkStorage } from '../storage/BulkStorage'; import {BulkStorage} from '../storage/BulkStorage';
import { createRoute } from './Route'; import {createRoute} from './Route';
const bulkDoneRouteModel = new SCBulkDoneRoute(); const bulkDoneRouteModel = new SCBulkDoneRoute();

View File

@@ -13,9 +13,9 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCBulkRequest, SCBulkResponse, SCBulkRoute } from '@openstapps/core'; import {SCBulkRequest, SCBulkResponse, SCBulkRoute} from '@openstapps/core';
import { BulkStorage } from '../storage/BulkStorage'; import {BulkStorage} from '../storage/BulkStorage';
import { createRoute } from './Route'; import {createRoute} from './Route';
const bulkRouteModel = new SCBulkRoute(); const bulkRouteModel = new SCBulkRoute();

View File

@@ -13,9 +13,9 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCConfigFile, SCIndexResponse, SCIndexRoute } from '@openstapps/core'; import {SCConfigFile, SCIndexResponse, SCIndexRoute} from '@openstapps/core';
import * as config from 'config'; import * as config from 'config';
import { createRoute } from './Route'; import {createRoute} from './Route';
const indexRouteModel = new SCIndexRoute(); const indexRouteModel = new SCIndexRoute();

View File

@@ -20,8 +20,8 @@ import {
SCSearchResponse, SCSearchResponse,
SCTooManyRequestsErrorResponse, SCTooManyRequestsErrorResponse,
} from '@openstapps/core'; } from '@openstapps/core';
import { BulkStorage } from '../storage/BulkStorage'; import {BulkStorage} from '../storage/BulkStorage';
import { createRoute } from './Route'; import {createRoute} from './Route';
const multiSearchRouteModel = new SCMultiSearchRoute(); const multiSearchRouteModel = new SCMultiSearchRoute();

View File

@@ -19,11 +19,11 @@ import {
SCRoute, SCRoute,
SCValidationErrorResponse, SCValidationErrorResponse,
} from '@openstapps/core'; } from '@openstapps/core';
import { SCValidator } from '@openstapps/core-validator'; import {SCValidator} from '@openstapps/core-validator';
import { Application, Router } from 'express'; import {Application, Router} from 'express';
import PromiseRouter from 'express-promise-router'; import PromiseRouter from 'express-promise-router';
import { logger } from '../common'; import {logger} from '../common';
import { isHttpMethod } from './HTTPTypes'; import {isHttpMethod} from './HTTPTypes';
/** /**
* Creates a router from a route class (model of a route) and a handler function which implements the logic * Creates a router from a route class (model of a route) and a handler function which implements the logic
@@ -39,7 +39,7 @@ export function createRoute<RETURNTYPE>(
handler: (validatedBody: any, app: Application, params?: { [parameterName: string]: string }) => Promise<RETURNTYPE>, handler: (validatedBody: any, app: Application, params?: { [parameterName: string]: string }) => Promise<RETURNTYPE>,
): Router { ): Router {
// create router // create router
const router = PromiseRouter({ mergeParams: true }); const router = PromiseRouter({mergeParams: true});
// create route // create route
// the given type has no index signature so we have to cast to get the IRouteHandler when a HTTP method is given // the given type has no index signature so we have to cast to get the IRouteHandler when a HTTP method is given

View File

@@ -13,9 +13,9 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCSearchRequest, SCSearchResponse, SCSearchRoute } from '@openstapps/core'; import {SCSearchRequest, SCSearchResponse, SCSearchRoute} from '@openstapps/core';
import { BulkStorage } from '../storage/BulkStorage'; import {BulkStorage} from '../storage/BulkStorage';
import { createRoute } from './Route'; import {createRoute} from './Route';
const searchRouteModel = new SCSearchRoute(); const searchRouteModel = new SCSearchRoute();

View File

@@ -13,9 +13,9 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCThingUpdateRequest, SCThingUpdateResponse, SCThingUpdateRoute } from '@openstapps/core'; import {SCThingUpdateRequest, SCThingUpdateResponse, SCThingUpdateRoute} from '@openstapps/core';
import { BulkStorage } from '../storage/BulkStorage'; import {BulkStorage} from '../storage/BulkStorage';
import { createRoute } from './Route'; import {createRoute} from './Route';
const thingUpdateRouteModel = new SCThingUpdateRoute(); const thingUpdateRouteModel = new SCThingUpdateRoute();

View File

@@ -13,13 +13,13 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCBulkRequest, SCThingTypes } from '@openstapps/core'; import {SCBulkRequest, SCThingTypes} from '@openstapps/core';
import * as moment from 'moment'; import * as moment from 'moment';
import * as NodeCache from 'node-cache'; import * as NodeCache from 'node-cache';
import { promisify } from 'util'; import {promisify} from 'util';
import { v4 } from 'uuid'; import {v4} from 'uuid';
import { logger } from '../common'; import {logger} from '../common';
import { Database } from './Database'; import {Database} from './Database';
export type BulkOperation = 'create' | 'expired' | 'update'; export type BulkOperation = 'create' | 'expired' | 'update';
@@ -102,7 +102,7 @@ export class BulkStorage {
// a bulk lives 60 minutes if no expiration is given // a bulk lives 60 minutes if no expiration is given
// the cache is checked every 60 seconds // the cache is checked every 60 seconds
this.cache = new NodeCache({ stdTTL: 3600, checkperiod: 60 }); this.cache = new NodeCache({stdTTL: 3600, checkperiod: 60});
this.cache.on('expired', (_key, bulk: Bulk) => { this.cache.on('expired', (_key, bulk: Bulk) => {
// if the bulk is not done // if the bulk is not done

View File

@@ -13,12 +13,10 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCSearchQuery, SCSearchResponse, SCThings, SCUuid } from '@openstapps/core'; import {SCSearchQuery, SCSearchResponse, SCThings, SCUuid} from '@openstapps/core';
import {Bulk} from './BulkStorage'; import {Bulk} from './BulkStorage';
export interface DatabaseConstructor { export type DatabaseConstructor = new (...args: any) => Database;
new (...args: any): Database;
}
export interface Database { export interface Database {

View File

@@ -25,15 +25,15 @@ import {
} from '@openstapps/core'; } from '@openstapps/core';
import * as ES from 'elasticsearch'; import * as ES from 'elasticsearch';
import * as moment from 'moment'; import * as moment from 'moment';
import { logger } from '../../common'; import {logger} from '../../common';
import { MailQueue } from '../../notification/MailQueue'; import {MailQueue} from '../../notification/MailQueue';
import { Bulk } from '../BulkStorage'; import {Bulk} from '../BulkStorage';
import { Database } from '../Database'; import {Database} from '../Database';
import { buildAggregations, parseAggregations } from './aggregations'; import {buildAggregations, parseAggregations} from './aggregations';
import { AggregationSchema, ElasticsearchConfig, ElasticsearchObject } from './common'; import {AggregationSchema, ElasticsearchConfig, ElasticsearchObject} from './common';
import * as Monitoring from './monitoring'; import * as Monitoring from './monitoring';
import { buildQuery, buildSort } from './query'; import {buildQuery, buildSort} from './query';
import { putTemplate } from './templating'; import {putTemplate} from './templating';
// this will match index names such as stapps_<type>_<source>_<random suffix> // this will match index names such as stapps_<type>_<source>_<random suffix>
const indexRegex = /^stapps_([A-z0-9_]+)_([a-z0-9-_]+)_([-a-z0-9^_]+)$/; const indexRegex = /^stapps_([A-z0-9_]+)_([a-z0-9-_]+)_([-a-z0-9^_]+)$/;
@@ -276,7 +276,7 @@ export class Elasticsearch implements Database {
// don't delete indices that are in use already // don't delete indices that are in use already
if (bulk.state !== 'done') { if (bulk.state !== 'done') {
logger.info('deleting obsolete index', index); logger.info('deleting obsolete index', index);
return await this.client.indices.delete({ index }); return await this.client.indices.delete({index});
} }
} }
@@ -309,7 +309,7 @@ export class Elasticsearch implements Database {
} }
// create the new index if it does not exists // create the new index if it does not exists
if (!(await this.client.indices.exists({ index }))) { if (!(await this.client.indices.exists({index}))) {
// re-apply the index template before each new bulk operation // re-apply the index template before each new bulk operation
await putTemplate(this.client); await putTemplate(this.client);
await this.client.indices.create({ await this.client.indices.create({
@@ -323,14 +323,14 @@ export class Elasticsearch implements Database {
// add our new index to the alias // add our new index to the alias
const actions: ES.IndicesUpdateAliasesParamsAction[] = [ const actions: ES.IndicesUpdateAliasesParamsAction[] = [
{ {
add: { index: index, alias: alias }, add: {index: index, alias: alias},
}, },
]; ];
// remove our old index if it exists // remove our old index if it exists
if (typeof oldIndex === 'string') { if (typeof oldIndex === 'string') {
actions.push({ actions.push({
remove: { index: oldIndex, alias: alias }, remove: {index: oldIndex, alias: alias},
}); });
} }
@@ -350,7 +350,7 @@ export class Elasticsearch implements Database {
this.aliasMap[alias][bulk.source] = index; this.aliasMap[alias][bulk.source] = index;
if (typeof oldIndex === 'string') { if (typeof oldIndex === 'string') {
// delete the old index // delete the old index
await this.client.indices.delete({ index: oldIndex }); await this.client.indices.delete({index: oldIndex});
logger.info('deleted old index', oldIndex); logger.info('deleted old index', oldIndex);
} }
logger.info('swapped alias index alias', oldIndex, '=>', index); logger.info('swapped alias index alias', oldIndex, '=>', index);

View File

@@ -13,8 +13,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCBackendAggregationConfiguration, SCFacet, SCThingTypes } from '@openstapps/core'; import {SCBackendAggregationConfiguration, SCFacet, SCThingTypes} from '@openstapps/core';
import { AggregationSchema } from './common'; import {AggregationSchema} from './common';
export type aggregationType = SCThingTypes | '@all'; export type aggregationType = SCThingTypes | '@all';

View File

@@ -13,8 +13,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { SCThingTypes } from '@openstapps/core'; import {SCThingTypes} from '@openstapps/core';
import { SCThing } from '@openstapps/core'; import {SCThing} from '@openstapps/core';
/** /**
* An elasticsearch bucket aggregation * An elasticsearch bucket aggregation

View File

@@ -22,8 +22,8 @@ import {
} from '@openstapps/core'; } from '@openstapps/core';
import * as ES from 'elasticsearch'; import * as ES from 'elasticsearch';
import * as cron from 'node-cron'; import * as cron from 'node-cron';
import { logger } from '../../common'; import {logger} from '../../common';
import { MailQueue } from '../../notification/MailQueue'; import {MailQueue} from '../../notification/MailQueue';
/** /**
* Check if the given condition fails on the given number of results and the condition * Check if the given condition fails on the given number of results and the condition

View File

@@ -24,7 +24,7 @@ import {
SCThingsField, SCThingsField,
SCThingTypes, SCThingTypes,
} from '@openstapps/core'; } from '@openstapps/core';
import { ElasticsearchConfig, ScriptSort } from './common'; import {ElasticsearchConfig, ScriptSort} from './common';
import { import {
ESBooleanFilter, ESBooleanFilter,
ESBooleanFilterArguments, ESBooleanFilterArguments,

View File

@@ -15,8 +15,8 @@
*/ */
import {Client} from 'elasticsearch'; import {Client} from 'elasticsearch';
import {readdir, readFile} from 'fs-extra'; import {readdir, readFile} from 'fs-extra';
import { resolve } from 'path'; import {resolve} from 'path';
import { logger } from '../../common'; import {logger} from '../../common';
/** /**
* Assembles an elasticsearch template with all resolved subType-references * Assembles an elasticsearch template with all resolved subType-references