mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
style: remove extraneous whitespace in imports
This commit is contained in:
committed by
Rainer Killinger
parent
16bbb7e9e3
commit
98f02b8830
28
src/app.ts
28
src/app.ts
@@ -13,25 +13,25 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCNotFoundErrorResponse, SCUnsupportedMediaTypeErrorResponse } from '@openstapps/core';
|
||||
import { SCValidator } from '@openstapps/core-validator';
|
||||
import {SCNotFoundErrorResponse, SCUnsupportedMediaTypeErrorResponse} from '@openstapps/core';
|
||||
import {SCValidator} from '@openstapps/core-validator';
|
||||
import * as bodyParser from 'body-parser';
|
||||
import * as config from 'config';
|
||||
import * as cors from 'cors';
|
||||
import * as express from 'express';
|
||||
import * as morgan from 'morgan';
|
||||
import { logger, mailer } from './common';
|
||||
import { MailQueue } from './notification/MailQueue';
|
||||
import { bulkAddRouter } from './routes/BulkAddRoute';
|
||||
import { bulkDoneRouter } from './routes/BulkDoneRoute';
|
||||
import { bulkRouter } from './routes/BulkRoute';
|
||||
import { indexRouter } from './routes/IndexRoute';
|
||||
import { multiSearchRouter } from './routes/MultiSearchRoute';
|
||||
import { searchRouter } from './routes/SearchRoute';
|
||||
import { thingUpdateRouter } from './routes/ThingUpdateRoute';
|
||||
import { BulkStorage } from './storage/BulkStorage';
|
||||
import { DatabaseConstructor } from './storage/Database';
|
||||
import { Elasticsearch } from './storage/elasticsearch/Elasticsearch';
|
||||
import {logger, mailer} from './common';
|
||||
import {MailQueue} from './notification/MailQueue';
|
||||
import {bulkAddRouter} from './routes/BulkAddRoute';
|
||||
import {bulkDoneRouter} from './routes/BulkDoneRoute';
|
||||
import {bulkRouter} from './routes/BulkRoute';
|
||||
import {indexRouter} from './routes/IndexRoute';
|
||||
import {multiSearchRouter} from './routes/MultiSearchRoute';
|
||||
import {searchRouter} from './routes/SearchRoute';
|
||||
import {thingUpdateRouter} from './routes/ThingUpdateRoute';
|
||||
import {BulkStorage} from './storage/BulkStorage';
|
||||
import {DatabaseConstructor} from './storage/Database';
|
||||
import {Elasticsearch} from './storage/elasticsearch/Elasticsearch';
|
||||
|
||||
export const app = express();
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import * as http from 'http';
|
||||
import { app } from './app';
|
||||
import { logger } from './common';
|
||||
import {app} from './app';
|
||||
import {logger} from './common';
|
||||
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { Logger } from '@openstapps/logger';
|
||||
import { BackendTransport } from './notification/BackendTransport';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {BackendTransport} from './notification/BackendTransport';
|
||||
|
||||
export const mailer = BackendTransport.getTransportInstance();
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SMTP } from '@openstapps/logger/lib/SMTP';
|
||||
import { MailOptions } from 'nodemailer/lib/sendmail-transport';
|
||||
import {SMTP} from '@openstapps/logger/lib/SMTP';
|
||||
import {MailOptions} from 'nodemailer/lib/sendmail-transport';
|
||||
import * as Queue from 'promise-queue';
|
||||
import { logger } from '../common';
|
||||
import {logger} from '../common';
|
||||
/**
|
||||
* A queue that can send mails in serial
|
||||
*/
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCBulkAddRequest, SCBulkAddResponse, SCBulkAddRoute, SCNotFoundErrorResponse } from '@openstapps/core';
|
||||
import { logger } from '../common';
|
||||
import { BulkStorage } from '../storage/BulkStorage';
|
||||
import { createRoute } from './Route';
|
||||
import {SCBulkAddRequest, SCBulkAddResponse, SCBulkAddRoute, SCNotFoundErrorResponse} from '@openstapps/core';
|
||||
import {logger} from '../common';
|
||||
import {BulkStorage} from '../storage/BulkStorage';
|
||||
import {createRoute} from './Route';
|
||||
|
||||
const bulkRouteModel = new SCBulkAddRoute();
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCBulkDoneRequest, SCBulkDoneResponse, SCBulkDoneRoute, SCNotFoundErrorResponse } from '@openstapps/core';
|
||||
import { logger } from '../common';
|
||||
import { BulkStorage } from '../storage/BulkStorage';
|
||||
import { createRoute } from './Route';
|
||||
import {SCBulkDoneRequest, SCBulkDoneResponse, SCBulkDoneRoute, SCNotFoundErrorResponse} from '@openstapps/core';
|
||||
import {logger} from '../common';
|
||||
import {BulkStorage} from '../storage/BulkStorage';
|
||||
import {createRoute} from './Route';
|
||||
|
||||
const bulkDoneRouteModel = new SCBulkDoneRoute();
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCBulkRequest, SCBulkResponse, SCBulkRoute } from '@openstapps/core';
|
||||
import { BulkStorage } from '../storage/BulkStorage';
|
||||
import { createRoute } from './Route';
|
||||
import {SCBulkRequest, SCBulkResponse, SCBulkRoute} from '@openstapps/core';
|
||||
import {BulkStorage} from '../storage/BulkStorage';
|
||||
import {createRoute} from './Route';
|
||||
|
||||
const bulkRouteModel = new SCBulkRoute();
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCConfigFile, SCIndexResponse, SCIndexRoute } from '@openstapps/core';
|
||||
import {SCConfigFile, SCIndexResponse, SCIndexRoute} from '@openstapps/core';
|
||||
import * as config from 'config';
|
||||
import { createRoute } from './Route';
|
||||
import {createRoute} from './Route';
|
||||
|
||||
const indexRouteModel = new SCIndexRoute();
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import {
|
||||
SCSearchResponse,
|
||||
SCTooManyRequestsErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import { BulkStorage } from '../storage/BulkStorage';
|
||||
import { createRoute } from './Route';
|
||||
import {BulkStorage} from '../storage/BulkStorage';
|
||||
import {createRoute} from './Route';
|
||||
|
||||
const multiSearchRouteModel = new SCMultiSearchRoute();
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ import {
|
||||
SCRoute,
|
||||
SCValidationErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import { SCValidator } from '@openstapps/core-validator';
|
||||
import { Application, Router } from 'express';
|
||||
import {SCValidator} from '@openstapps/core-validator';
|
||||
import {Application, Router} from 'express';
|
||||
import PromiseRouter from 'express-promise-router';
|
||||
import { logger } from '../common';
|
||||
import { isHttpMethod } from './HTTPTypes';
|
||||
import {logger} from '../common';
|
||||
import {isHttpMethod} from './HTTPTypes';
|
||||
|
||||
/**
|
||||
* 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>,
|
||||
): Router {
|
||||
// create router
|
||||
const router = PromiseRouter({ mergeParams: true });
|
||||
const router = PromiseRouter({mergeParams: true});
|
||||
|
||||
// create route
|
||||
// the given type has no index signature so we have to cast to get the IRouteHandler when a HTTP method is given
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCSearchRequest, SCSearchResponse, SCSearchRoute } from '@openstapps/core';
|
||||
import { BulkStorage } from '../storage/BulkStorage';
|
||||
import { createRoute } from './Route';
|
||||
import {SCSearchRequest, SCSearchResponse, SCSearchRoute} from '@openstapps/core';
|
||||
import {BulkStorage} from '../storage/BulkStorage';
|
||||
import {createRoute} from './Route';
|
||||
|
||||
const searchRouteModel = new SCSearchRoute();
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCThingUpdateRequest, SCThingUpdateResponse, SCThingUpdateRoute } from '@openstapps/core';
|
||||
import { BulkStorage } from '../storage/BulkStorage';
|
||||
import { createRoute } from './Route';
|
||||
import {SCThingUpdateRequest, SCThingUpdateResponse, SCThingUpdateRoute} from '@openstapps/core';
|
||||
import {BulkStorage} from '../storage/BulkStorage';
|
||||
import {createRoute} from './Route';
|
||||
|
||||
const thingUpdateRouteModel = new SCThingUpdateRoute();
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCBulkRequest, SCThingTypes } from '@openstapps/core';
|
||||
import {SCBulkRequest, SCThingTypes} from '@openstapps/core';
|
||||
import * as moment from 'moment';
|
||||
import * as NodeCache from 'node-cache';
|
||||
import { promisify } from 'util';
|
||||
import { v4 } from 'uuid';
|
||||
import { logger } from '../common';
|
||||
import { Database } from './Database';
|
||||
import {promisify} from 'util';
|
||||
import {v4} from 'uuid';
|
||||
import {logger} from '../common';
|
||||
import {Database} from './Database';
|
||||
|
||||
export type BulkOperation = 'create' | 'expired' | 'update';
|
||||
|
||||
@@ -102,7 +102,7 @@ export class BulkStorage {
|
||||
|
||||
// a bulk lives 60 minutes if no expiration is given
|
||||
// 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) => {
|
||||
// if the bulk is not done
|
||||
|
||||
@@ -13,12 +13,10 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCSearchQuery, SCSearchResponse, SCThings, SCUuid } from '@openstapps/core';
|
||||
import {SCSearchQuery, SCSearchResponse, SCThings, SCUuid} from '@openstapps/core';
|
||||
import {Bulk} from './BulkStorage';
|
||||
|
||||
export interface DatabaseConstructor {
|
||||
new (...args: any): Database;
|
||||
}
|
||||
export type DatabaseConstructor = new (...args: any) => Database;
|
||||
|
||||
export interface Database {
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@ import {
|
||||
} from '@openstapps/core';
|
||||
import * as ES from 'elasticsearch';
|
||||
import * as moment from 'moment';
|
||||
import { logger } from '../../common';
|
||||
import { MailQueue } from '../../notification/MailQueue';
|
||||
import { Bulk } from '../BulkStorage';
|
||||
import { Database } from '../Database';
|
||||
import { buildAggregations, parseAggregations } from './aggregations';
|
||||
import { AggregationSchema, ElasticsearchConfig, ElasticsearchObject } from './common';
|
||||
import {logger} from '../../common';
|
||||
import {MailQueue} from '../../notification/MailQueue';
|
||||
import {Bulk} from '../BulkStorage';
|
||||
import {Database} from '../Database';
|
||||
import {buildAggregations, parseAggregations} from './aggregations';
|
||||
import {AggregationSchema, ElasticsearchConfig, ElasticsearchObject} from './common';
|
||||
import * as Monitoring from './monitoring';
|
||||
import { buildQuery, buildSort } from './query';
|
||||
import { putTemplate } from './templating';
|
||||
import {buildQuery, buildSort} from './query';
|
||||
import {putTemplate} from './templating';
|
||||
|
||||
// this will match index names such as stapps_<type>_<source>_<random suffix>
|
||||
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
|
||||
if (bulk.state !== 'done') {
|
||||
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
|
||||
if (!(await this.client.indices.exists({ index }))) {
|
||||
if (!(await this.client.indices.exists({index}))) {
|
||||
// re-apply the index template before each new bulk operation
|
||||
await putTemplate(this.client);
|
||||
await this.client.indices.create({
|
||||
@@ -323,14 +323,14 @@ export class Elasticsearch implements Database {
|
||||
// add our new index to the alias
|
||||
const actions: ES.IndicesUpdateAliasesParamsAction[] = [
|
||||
{
|
||||
add: { index: index, alias: alias },
|
||||
add: {index: index, alias: alias},
|
||||
},
|
||||
];
|
||||
|
||||
// remove our old index if it exists
|
||||
if (typeof oldIndex === 'string') {
|
||||
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;
|
||||
if (typeof oldIndex === 'string') {
|
||||
// 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('swapped alias index alias', oldIndex, '=>', index);
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCBackendAggregationConfiguration, SCFacet, SCThingTypes } from '@openstapps/core';
|
||||
import { AggregationSchema } from './common';
|
||||
import {SCBackendAggregationConfiguration, SCFacet, SCThingTypes} from '@openstapps/core';
|
||||
import {AggregationSchema} from './common';
|
||||
|
||||
export type aggregationType = SCThingTypes | '@all';
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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/>.
|
||||
*/
|
||||
import { SCThingTypes } from '@openstapps/core';
|
||||
import { SCThing } from '@openstapps/core';
|
||||
import {SCThingTypes} from '@openstapps/core';
|
||||
import {SCThing} from '@openstapps/core';
|
||||
|
||||
/**
|
||||
* An elasticsearch bucket aggregation
|
||||
|
||||
@@ -22,8 +22,8 @@ import {
|
||||
} from '@openstapps/core';
|
||||
import * as ES from 'elasticsearch';
|
||||
import * as cron from 'node-cron';
|
||||
import { logger } from '../../common';
|
||||
import { MailQueue } from '../../notification/MailQueue';
|
||||
import {logger} from '../../common';
|
||||
import {MailQueue} from '../../notification/MailQueue';
|
||||
|
||||
/**
|
||||
* Check if the given condition fails on the given number of results and the condition
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
SCThingsField,
|
||||
SCThingTypes,
|
||||
} from '@openstapps/core';
|
||||
import { ElasticsearchConfig, ScriptSort } from './common';
|
||||
import {ElasticsearchConfig, ScriptSort} from './common';
|
||||
import {
|
||||
ESBooleanFilter,
|
||||
ESBooleanFilterArguments,
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
import {Client} from 'elasticsearch';
|
||||
import {readdir, readFile} from 'fs-extra';
|
||||
import { resolve } from 'path';
|
||||
import { logger } from '../../common';
|
||||
import {resolve} from 'path';
|
||||
import {logger} from '../../common';
|
||||
|
||||
/**
|
||||
* Assembles an elasticsearch template with all resolved subType-references
|
||||
|
||||
Reference in New Issue
Block a user