mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Update optics agent to 1.1 (#14935)
This commit is contained in:
parent
1177bba215
commit
68f87621d2
11
optics-agent/index.d.ts
vendored
11
optics-agent/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for optics-agent 1.0
|
||||
// Type definitions for optics-agent 1.1
|
||||
// Project: https://github.com/apollostack/optics-agent-js#readme
|
||||
// Definitions by: Crevil <https://github.com/crevil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@ -6,6 +6,7 @@
|
||||
import { GraphQLSchema } from "graphql";
|
||||
import { Request, Response } from "express";
|
||||
import { Server } from "hapi";
|
||||
import { Context } from "koa";
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
@ -57,6 +58,11 @@ export interface Options {
|
||||
* Send the query variables along with traces. Defaults to true.
|
||||
*/
|
||||
reportVariables?: boolean;
|
||||
|
||||
/**
|
||||
* Send statistics when the process exits. Defaults to true.
|
||||
*/
|
||||
shutdownGracefully?: boolean;
|
||||
}
|
||||
|
||||
export class Agent {
|
||||
@ -64,6 +70,7 @@ export class Agent {
|
||||
|
||||
configureAgent(options: Options): Agent;
|
||||
instrumentSchema(schema: GraphQLSchema): void;
|
||||
koaMiddleware(): (context: Context, next: () => Promise<any>) => void;
|
||||
middleware(): (req: Request, res: Response, next?: any) => void;
|
||||
instrumentHapiServer(server: Server): void;
|
||||
context(req: Request): any;
|
||||
@ -71,6 +78,7 @@ export class Agent {
|
||||
|
||||
export function configureAgent(options: Options): Agent;
|
||||
export function instrumentSchema(schema: GraphQLSchema): void;
|
||||
export function koaMiddleware(): (context: Context, next: () => Promise<any>) => void;
|
||||
export function middleware(): (req: Request, res: Response, next?: any) => void;
|
||||
export function instrumentHapiServer(server: Server): void;
|
||||
export function context(req: Request): any;
|
||||
@ -78,6 +86,7 @@ export function context(req: Request): any;
|
||||
export default {
|
||||
configureAgent,
|
||||
instrumentSchema,
|
||||
koaMiddleware,
|
||||
middleware,
|
||||
instrumentHapiServer,
|
||||
context,
|
||||
|
||||
@ -4,12 +4,14 @@ import OpticsAgent, {
|
||||
middleware,
|
||||
instrumentHapiServer,
|
||||
context,
|
||||
Options,
|
||||
} from 'optics-agent';
|
||||
import { GraphQLSchema } from 'graphql';
|
||||
import * as express from 'express';
|
||||
import * as hapi from 'hapi';
|
||||
import * as KoaServer from 'koa';
|
||||
|
||||
const configOptions = {
|
||||
const configOptions: Options = {
|
||||
apiKey: "",
|
||||
reportTraces: false,
|
||||
reportVariables: false,
|
||||
@ -18,6 +20,7 @@ const configOptions = {
|
||||
endpointUrl: "",
|
||||
proxyUrl: "",
|
||||
reportIntervalMs: 1,
|
||||
shutdownGracefully: false,
|
||||
};
|
||||
OpticsAgent.configureAgent(configOptions);
|
||||
|
||||
@ -27,6 +30,9 @@ expressServer.use(OpticsAgent.middleware());
|
||||
const hapiServer = new hapi.Server();
|
||||
OpticsAgent.instrumentHapiServer(hapiServer);
|
||||
|
||||
const koaServer = new KoaServer();
|
||||
koaServer.use(OpticsAgent.koaMiddleware());
|
||||
|
||||
const req = {} as express.Request;
|
||||
OpticsAgent.context(req);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user