Appear JS introspector
Unlock the full potential of your existing APIs @ Appear.sh
Appear is a API development platform that helps companies understand, improve and manage their internal APIs.
This JS introspector is a tool that listens to both incoming and outgoing traffic in JS runtime (browser, node) and detects the shape (schema) of it and reports this schema to Appear platform where it's further merged, processed and analyzed.
Because it reports only schema of the traffic it never sends any actual content of the data nor PII.
Usage
- Install using your favourite package manager
npm i @appear.sh/introspector
yarn add @appear.sh/introspector
pnpm add @appear.sh/introspector
- In entrypoint of your service initialise the introspector
Appear.init({
apiKey: "your-api-key",
environment: process.env.NODE_ENV,
})
- If your service hosts a HTTP server (such as Express, NestJS etc) sometimes you'll have to "hook" things before your application actually starts. To do this, we expose a
@appear.sh/introspector/hook
package that does this for you. The easiest way to use this is to modify your node
executable parameters.
Before: node build/server.js
After: node -r @appear.sh/introspector/hook build/server.js
- you're done, now you can login into app.appear.sh and see what's being reported
Configuration
export interface AppearConfig {
apiKey: string
environment: string
enabled?: boolean
reporting?: {
endpoint?: string
batchIntervalSeconds?: number
batchSize?: number
}
interception?: {
disableXHR?: boolean
filter?: (
request: Request,
response: Response,
config: ResolvedAppearConfig,
) => boolean
}
}
Framework specific integrations
Not all services are deployed as a node applications. If that applies to you, you can either use one of pre-built integrations, or write your own adapter.
RedwoodJS at vercel
- Create a file where you can instantiate Appear, for example:
api/src/withAppear.ts
import { createVercelMiddleware } from "@appear.sh/introspector/integrations/redwoodjs"
export const withAppear = createVercelMiddleware({
apiKey: "your-api-key",
environment: process.env.NODE_ENV,
})
- Wrap your Serverless Functions (API Endpoints) in
withAppear
import { withAppear } from "src/withAppear"
export const handler = withAppear(async (event, context) => {
})
- Once finished, any calls to your APIs should show up in Appear
Next.JS server-side integration at vercel
Note:
only pages router is supported at this moment. If you'd like app router support please let us know on support@appear.sh
- Create a file where you can instantiate Appear, for example:
api/src/withAppear.ts
import { createVercelPagesMiddleware } from "@appear.sh/introspector/integrations/nextjs"
export const withAppear = createVercelPagesMiddleware({
apiKey: "your-api-key",
environment: process.env.NODE_ENV,
})
- Wrap your API Routes in
withAppear
import { withAppear } from "src/withAppear"
export default withAppear(async (req, res) => {
})
- Patch webpack configuration in
next.config.js
const {
withAppearConfig,
} = require("@appear.sh/introspector/integrations/nextjs")
const nextConfig = {
}
module.exports = withAppearConfig(nextConfig)
- Once finished, any calls to your APIs should show up in Appear