import { SubscriptionServerOptions } from 'apollo-server-core'; import { PlaygroundRenderPageOptions } from 'apollo-server-express'; import { CorsOptions as OriginalCorsOption } from 'cors'; import * as Setset from 'setset'; import { LiteralUnion, Primitive } from 'type-fest'; import { ApolloConfigEngine } from './apollo-server/types'; declare type ResolvedOptional = Exclude, Primitive>; export declare type ServerSettingsManager = Setset.Manager; export declare type HTTPMethods = LiteralUnion<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD', string>; export declare type PlaygroundLonghandInput = { /** * Should the [GraphQL Playground](https://github.com/prisma-labs/graphql-playground) be hosted by the server? * * @dynamicDefault * * - If not production then `true` * - Otherwise `false` * * @remarks * * GraphQL Playground is useful during development as a visual client to interact with your API. In * production, without some kind of security/access control, you will almost * certainly want it disabled. */ enabled?: boolean; /** * Configure the settings of the GraphQL Playground app itself. */ settings?: Omit>, 'general.betaUpdates'>; }; declare type SubscriptionsLonghandInput = Omit & { /** * The path for clients to send subscriptions to. * * @default "/graphql" */ path?: string; /** * Disable or enable the subscriptions server. * * @dynamicDefault * * - true if there is a Subscription type in your schema * - false otherwise */ enabled?: boolean; }; export declare type SettingsInput = { /** * Configure the subscriptions server. * * - Pass true to force enable with setting defaults * - Pass false to force disable * - Pass settings to customize config. Note does not imply enabled. Set "enabled: true" for that or rely on default. * * @dynamicDefault * * - true if there is a Subscription type in your schema * - false otherwise */ subscriptions?: boolean | SubscriptionsLonghandInput; /** * Port the server should be listening on. * * todo default */ port?: number; /** * Host the server should be listening on. * * todo default */ host?: string | undefined; /** * Configure the [GraphQL Playground](https://github.com/prisma-labs/graphql-playground) hosted by the server. * * - Pass `true` as shorthand for `{ enabled: true }` * - Pass `false` as shorthand for `{ enabled: false }` * - Pass an object to configure * * @dynamicDefault * * - If not production then `true` * - Otherwise `false` * * @remarks * * GraphQL Playground is useful during development as a visual client to interact with your API. In * production, without some kind of security/access control, you will almost * certainly want it disabled. */ playground?: boolean | PlaygroundLonghandInput; /** * Enable CORS for your server * * When true is passed, the default config is the following: * * ``` * { * "origin": "*", * "methods": "GET,HEAD,PUT,PATCH,POST,DELETE", * "preflightContinue": false, * "optionsSuccessStatus": 204 * } * ``` * * @default false */ cors?: boolean | { /** * Enable or disable CORS. * * @default true */ enabled?: boolean; /** * Configures the Access-Control-Allow-Origin CORS header. Possible values: * * Boolean - set origin to true to reflect the request origin, as defined by req.header('Origin'), or set it to false to disable CORS. * * String - set origin to a specific origin. For example if you set it to "http://example.com" only requests from "http://example.com" will be allowed. * * RegExp - set origin to a regular expression pattern which will be used to test the request origin. If it's a match, the request origin will be reflected. For example the pattern /example\.com$/ will reflect any request that is coming from an origin ending with "example.com". * * Array - set origin to an array of valid origins. Each origin can be a String or a RegExp. For example ["http://example1.com", /\.example2\.com$/] will accept any request from "http://example1.com" or from a subdomain of "example2.com". * * Function - set origin to a function implementing some custom logic. The function takes the request origin as the first parameter and a callback (called as callback(err, origin), where origin is a non-function value of the origin option) as the second. * */ origin?: OriginalCorsOption['origin']; /** * Configures the Access-Control-Allow-Methods CORS header. * * @example ['GET', 'PUT', 'POST'] */ methods?: string | HTTPMethods[]; /** * Configures the Access-Control-Allow-Headers CORS header. * * If not specified, defaults to reflecting the headers specified in the request's Access-Control-Request-Headers header. * * @example ['Content-Type', 'Authorization'] */ allowedHeaders?: string | string[]; /** * Configures the Access-Control-Expose-Headers CORS header. * * If not specified, no custom headers are exposed. * * @example ['Content-Range', 'X-Content-Range'] */ exposedHeaders?: string | string[]; /** * Configures the Access-Control-Allow-Credentials CORS header. * * Set to true to pass the header, otherwise it is omitted. */ credentials?: boolean; /** * Configures the Access-Control-Max-Age CORS header. * * Set to an integer to pass the header, otherwise it is omitted. */ maxAge?: number; /** * Pass the CORS preflight response to the next handler. */ preflightContinue?: boolean; /** * Provides a status code to use for successful OPTIONS requests, since some legacy browsers (IE11, various SmartTVs) choke on 204. */ optionsSuccessStatus?: number; }; /** * The path on which the GraphQL API should be served. * * @default /graphql */ path?: string; /** * Settings that are particualr to [Apollo](https://www.apollographql.com/). * * @remarks * * Under the hood Nexus' server implementation is powered by Apollo Server. You will not find all Apollo Server options here however. Only the ones that are particular to Apollo. Nexus does not consider generic server setting areas like CORS and GraphQL Playground as being Apollo settings. */ apollo?: { /** * The so-called "Apollo Reporting Options". For details about them refer [its official documentation](https://www.apollographql.com/docs/apollo-server/api/apollo-server/#enginereportingoptions). Many of the settings here are for Apollo Studio. You may also want to refer to its [official documentation](https://www.apollographql.com/docs/studio/schema/schema-reporting). * * - Pass false to disable * - Pass true to enable with defaults * - Pass an object of settings to customize the various options. This does not imply enabled. For that you must set "enabled: true". * * Some of these settings respond to special envars. * * - APOLLO_KEY -> apiKey * - APOLLO_GRAPH_VARIANT -> graphVariant * * @default false */ engine?: boolean | (ApolloConfigEngine & { enabled?: boolean; }); }; /** * Create a message suitable for printing to the terminal about the server * having been booted. */ startMessage?: (startInfo: ServerStartInfo) => void; /** * todo */ graphql?: { introspection?: boolean; }; }; declare type ServerStartInfo = { port: number; host: string; ip: string; paths: { graphql: string; graphqlSubscriptions: null | string; }; }; export declare type SettingsData = Setset.InferDataFromInput> & { host?: string; cors: ResolvedOptional; subscriptions: Omit & { enabled: boolean; path: string; }; apollo: { engine: ApolloConfigEngine & { enabled: boolean; }; }; }; export declare const createServerSettingsManager: () => Setset.Manager; export {}; //# sourceMappingURL=settings.d.ts.map