Deeplinks Node.js Client
A TypeScript/JavaScript client for the Deeplinks API built with axios.
Installation
npm install
npm run build
Usage
Basic Setup
import { DeeplinksClient } from "./dist";
const client = new DeeplinksClient({
baseURL: "http://localhost:3000",
apiKey: "your-api-key-here",
timeout: 30000,
});
Applications
const androidApp = await client.createApplication({
name: "My Android App",
platform: "android",
android: {
bundleId: "com.example.myapp",
certSHA256: ["sha256:..."],
},
});
const iosApp = await client.createApplication({
name: "My iOS App",
platform: "ios",
ios: {
bundleId: "com.example.myapp",
appId: "123456789",
teamId: "TEAM123",
},
});
await client.updateApplication(androidApp.id, {
name: "Updated App Name",
android: {
certSHA256: {
add: ["sha256:newcert"],
remove: ["sha256:oldcert"],
},
},
});
Domains
const domain = await client.createDomain({
domain: "example.com",
});
Dynamic Links
const dynamicLink = await client.createDynamicLink({
domain: "example.com",
urlSuffix: "product/123",
deepLinkUrl: "myapp://product/123",
name: "Product Link",
android: {
bundleId: "com.example.myapp",
fallbackTo: "store",
},
ios: {
bundleId: "com.example.myapp",
fallbackTo: "url",
fallbackUrl: "https://example.com/fallback",
},
});
const linkDetails = await client.fetchLinkDetails(dynamicLink.code, {
domain: "example.com",
});
Error Handling
try {
const application = await client.createApplication({
name: "My App",
platform: "android",
android: {
bundleId: "com.example.myapp",
},
});
} catch (error) {
if (error.status === 400) {
console.error("Bad request:", error.message);
} else if (error.status === 401) {
console.error("Unauthorized - check your API key");
} else if (error.status === 404) {
console.error("Resource not found");
} else {
console.error("Unexpected error:", error.message);
}
}
Custom Requests
const response = await client.request({
method: "GET",
url: "/custom-endpoint",
params: { custom: "param" },
});
API Reference
Constructor Options
apiKey (string): Required API key for authentication
baseURL (string): Base URL for the API (default: "http://localhost:3000")
timeout (number): Request timeout in milliseconds (default: 30000)
headers (object): Additional headers to include in requests
Methods
Applications
createApplication(data): Create a new application
updateApplication(id, data): Update an application by ID
Domains
createDomain(data): Create a new domain
Dynamic Links
createDynamicLink(data): Create a new dynamic link
fetchLinkDetails(code, params): Fetch dynamic link details by code
Utility
request(config): Make a custom request with full control
Development
Code Quality
This project uses the latest ESLint (v9) and Prettier for code quality and formatting:
- ESLint v9: Latest version with TypeScript support and modern rules
- Prettier: Code formatting with consistent style
- 4 spaces: Indentation using spaces
- Double quotes: String literals use double quotes
- Semicolons: Always required
- Trailing commas: Required in multiline structures
- Modern TypeScript: ES2024 target with strict type checking
Development Commands
npm install
npm run build
npm run dev
npm test
npm run lint
npm run lint:fix
npm run format
npm run format:check
npm run check
Code Style
The project follows these coding standards:
- Indentation: 4 spaces
- Quotes: Double quotes for strings
- Semicolons: Always required
- Trailing commas: Required in multiline structures
- Line length: 100 characters maximum
- Function spacing: Space before function parentheses for anonymous functions and arrow functions
- Modern JavaScript: ES2024 features and best practices
- TypeScript: Strict type checking with latest features
Configuration Files
.eslintrc.js: ESLint v9 configuration with TypeScript support
.eslintignore: ESLint ignore patterns
.prettierrc: Prettier configuration matching ESLint rules
tsconfig.json: TypeScript compiler configuration (ES2024)
ESLint Features
The latest ESLint configuration includes:
- Modern TypeScript rules: Latest TypeScript ESLint plugin
- Promise handling: Automatic detection of unhandled promises
- Nullish coalescing: Prefer
?? over || for null/undefined checks
- Optional chaining: Prefer
?. over manual null checks
- Arrow functions: Prefer arrow functions where appropriate
- Template literals: Prefer template literals over string concatenation
- Object shorthand: Use object property shorthand when possible
Types
The client includes full TypeScript support with comprehensive type definitions for all API requests and responses. See the src/types/index.ts file for complete type definitions.