-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move startup logic over to server plugin file and call from index.js
- Loading branch information
Aaron Caldwell
committed
Nov 19, 2019
1 parent
7593926
commit afcfe02
Showing
2 changed files
with
56 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { getImportRouteHandler } from './routes/file_upload'; | ||
import { getTelemetry, initTelemetry } from './telemetry/telemetry'; | ||
import { MAX_BYTES } from '../common/constants/file_import'; | ||
|
||
const TELEMETRY_TYPE = 'fileUploadTelemetry'; | ||
|
||
export class FileUploadPlugin { | ||
setup(core, plugins, __LEGACY) { | ||
const elasticsearchPlugin = __LEGACY.plugins.elasticsearch; | ||
const getSavedObjectsRepository = __LEGACY.savedObjects.getSavedObjectsRepository; | ||
const makeUsageCollector = __LEGACY.usage.collectorSet.makeUsageCollector; | ||
|
||
// Set up route | ||
__LEGACY.route({ | ||
method: 'POST', | ||
path: '/api/fileupload/import', | ||
handler: getImportRouteHandler(elasticsearchPlugin, getSavedObjectsRepository), | ||
config: { | ||
payload: { maxBytes: MAX_BYTES }, | ||
} | ||
}); | ||
|
||
// Make usage collector | ||
makeUsageCollector({ | ||
type: TELEMETRY_TYPE, | ||
isReady: () => true, | ||
fetch: async () => | ||
(await getTelemetry(elasticsearchPlugin, getSavedObjectsRepository)) || initTelemetry() | ||
}); | ||
} | ||
} |