diff --git a/packages/backend-common/config-schema.json b/packages/backend-common/config-schema.json deleted file mode 100644 index 2012447a11..0000000000 --- a/packages/backend-common/config-schema.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "$schema": "https://backstage.io/schema/config-v1", - "title": "@backstage/backend-common", - "type": "object", - "properties": { - "integrations": { - "type": "object", - "additionalProperties": false, - "properties": { - "github": { - "type": "array", - "items": { - "type": "object", - "required": ["host"], - "properties": { - "host": { - "type": "string" - }, - "token": { - "type": "string", - "visibility": "secret" - } - } - } - }, - "gitlab": { - "type": "array", - "items": { - "type": "object", - "required": ["host"], - "properties": { - "host": { - "type": "string" - }, - "token": { - "type": "string", - "visibility": "secret" - } - } - } - }, - "bitbucket": { - "type": "array", - "items": { - "type": "object", - "required": ["host"], - "properties": { - "host": { - "type": "string" - }, - "username": { - "type": "string" - }, - "appPassword": { - "type": "string", - "visibility": "secret" - } - } - } - }, - "azure": { - "type": "array", - "items": { - "type": "object", - "required": ["host"], - "properties": { - "host": { - "type": "string" - }, - "token": { - "type": "string", - "visibility": "secret" - } - } - } - } - } - } - } -} diff --git a/packages/backend-common/config.d.ts b/packages/backend-common/config.d.ts new file mode 100644 index 0000000000..64e883aa26 --- /dev/null +++ b/packages/backend-common/config.d.ts @@ -0,0 +1,148 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Config { + frontend: { + baseUrl: string; // defined in core, but repeated here without doc + }; + + backend: { + baseUrl: string; // defined in core, but repeated here without doc + /** Address that the backend should listen to. */ + + listen: + | string + | { + /** Address of the interface that the backend should bind to. */ + address?: string; + /** Port that the backend should listen to. */ + port?: number; + }; + + /** HTTPS configuration for the backend. If omitted the backend will serve HTTP */ + https?: { + /** Certificate configuration or parameters for generating a self-signed certificate */ + certificate?: + | { + /** Algorithm to use to generate a self-signed certificate */ + algorithm: string; + keySize?: number; + days?: number; + } + | { + /** PEM encoded certificate. Use $file to load in a file */ + cert: string; + /** + * PEM encoded certificate key. Use $file to load in a file. + * @visibility secret + */ + key: string; + }; + }; + + /** Database connection configuration, select database type using the `client` field */ + database: + | { + client: 'sqlite3'; + connection: ':memory:' | string; + } + | { + client: 'pg'; + /** + * PostgreSQL connection string or knex configuration object. + * @secret + */ + connection: string | object; + }; + + cors?: { + origin?: string | string[]; + methods?: string | string[]; + allowedHeaders?: string | string[]; + exposedHeaders?: string | string[]; + credentials?: boolean; + maxAge?: number; + preflightContinue?: boolean; + optionsSuccessStatus?: number; + }; + + /** */ + csp?: object; + }; + + /** Configuration for integrations towards various external repository provider systems */ + integrations: { + /** Integration configuration for Azure */ + azure: { + /** The hostname of the given Azure instance */ + host: string; + /** + * Token used to authenticate requests. + * @visibility secret + */ + token?: string; + }[]; + + /** Integration configuration for BitBucket */ + bitbucket: { + /** The hostname of the given Bitbucket instance */ + host: string; + /** + * Token used to authenticate requests. + * @visibility secret + */ + token?: string; + /** The base url for the BitBucket API, for example https://api.bitbucket.org/2.0 */ + apiBaseUrl?: string; + /** + * The username to use for authenticated requests. + * @visibility secret + */ + username?: string; + /** + * BitBucket app password used to authenticate requests. + * @visibility secret + */ + appPassword?: string; + }[]; + + /** Integration configuration for GitHub */ + github: { + /** The hostname of the given GitHub instance */ + host: string; + /** + * Token used to authenticate requests. + * @visibility secret + */ + token?: string; + /** The base url for the GitHub API, for example https://api.github.com */ + apiBaseUrl?: string; + /** The base url for GitHub raw resources, for example https://raw.githubusercontent.com */ + rawBaseUrl?: string; + }[]; + + /** Integration configuration for GitLab */ + gitlab: { + /** The hostname of the given GitLab instance */ + host: string; + /** + * Token used to authenticate requests. + * @visibility secret + */ + token?: string; + }[]; + }; +} diff --git a/packages/backend-common/package.json b/packages/backend-common/package.json index 2f58bd0536..737e9664bf 100644 --- a/packages/backend-common/package.json +++ b/packages/backend-common/package.json @@ -89,7 +89,8 @@ "supertest": "^4.0.2" }, "files": [ - "dist" + "dist", + "config.d.ts" ], - "configSchema": "config-schema.json" + "configSchema": "config.d.ts" }