
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
@differentialhq/core
Advanced tools
This is the official Differential SDK for Typescript.
npm install @differentialhq/core
yarn add @differentialhq/core
pnpm add @differentialhq/core
Create a file named d.ts which will be used to initialize Differential. This file will export the Differential instance.
// d.ts
import { Differential } from "@differentialhq/core";
// Initialize Differential with your API secret.
// Get yours at https://console.differential.dev.
export const d = new Differential("YOUR_API_SECRET");
In a separate file, create the "Hello World" service. This file will import the Differential instance from d.ts and define the service.
// service.ts
import { d } from "./d";
// Define a simple function that returns "Hello, World!"
const sayHello = async (to: string) => {
return `Hello, ${to}!`;
};
// ...and as many other functions as you want, any async function can be a service operation
const callEndpoint = async () => {
return fetch("https://api.example.com");
};
// Register the function as a service
export const helloWorldService = d.service({
name: "helloWorld",
functions: {
sayHello,
callEndpoint,
},
});
When calling the service, use the typeof generic to ensure type safety. This can be done in any file where you need to call the service, like a test file or another service file.
// service-consumer.ts
import { d } from "./d";
import type { helloWorldService } from "./service";
const client = d.client<typeof helloWorldService>("helloWorld");
async function test() {
const greeting = await client.sayHello("World");
console.log(greeting); // Outputs: Hello, World!
}
test();
To run the service, simply run the file with the service definition. This will start the service and make it available to other services.
tsx service.ts
and then you can invoke the service from another file:
tsx service-consumer.ts
FAQs
Javascript SDK for differential.dev
We found that @differentialhq/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.