plugfn
v0.0.1
Published
Self-hosted integration platform for developers - Connect your apps to the world
Maintainers
Readme
PlugFn TypeScript SDK
Self-hosted integration platform for TypeScript/JavaScript applications
Full-featured TypeScript SDK for building integrations with 75+ APIs.
Installation
npm install @superfunctions/plugfn @superfunctions/db @superfunctions/http
# Install framework adapter (choose one)
npm install @superfunctions/http-express
npm install @superfunctions/http-hono
npm install @superfunctions/http-fastify
npm install @superfunctions/http-nextQuick Start
1. Initialize PlugFn
import { plugFn } from '@superfunctions/plugfn';
import { drizzleAdapter } from '@superfunctions/db/adapters';
import { githubProvider } from '@superfunctions/plugfn/providers';
const plug = plugFn({
database: adapter,
auth: authProvider,
baseUrl: 'https://myapp.com',
encryptionKey: process.env.ENCRYPTION_KEY,
integrations: {
github: {
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
scopes: ['repo', 'issues', 'user']
}
}
});
plug.providers.register(githubProvider);2. Execute Actions
// Execute an action
const issue = await plug.github['issues.create']({
userId: 'user-123',
params: {
owner: 'myorg',
repo: 'myrepo',
title: 'Bug report',
body: 'Something is broken'
}
});3. Mount HTTP Endpoints
With Express
import express from 'express';
import { createPlugFnRouter } from '@superfunctions/plugfn/router';
import { toExpress } from '@superfunctions/http-express';
const app = express();
app.use(express.json());
const router = createPlugFnRouter(plug);
app.use('/api/plugfn', toExpress(router));
app.listen(3000);With Hono
import { Hono } from 'hono';
import { createPlugFnRouter } from '@superfunctions/plugfn/router';
import { toHono } from '@superfunctions/http-hono';
const app = new Hono();
const router = createPlugFnRouter(plug);
app.route('/api/plugfn', toHono(router));
export default app;With Fastify
import Fastify from 'fastify';
import { createPlugFnRouter } from '@superfunctions/plugfn/router';
import { toFastify } from '@superfunctions/http-fastify';
const fastify = Fastify();
const router = createPlugFnRouter(plug);
fastify.register(toFastify(router), { prefix: '/api/plugfn' });
await fastify.listen({ port: 3000 });Features
- ✅ Type-safe: Full TypeScript with auto-complete
- ✅ OAuth built-in: Complete OAuth 2.0 flow
- ✅ Webhooks: Real-time event handling
- ✅ Workflows: Chain actions together
- ✅ 5 providers: GitHub, Slack, Discord, Linear, Stripe
- ✅ Framework-agnostic: Works with Express, Hono, Fastify, Next.js, SvelteKit
- ✅ Testing utilities: Mock providers and workflows
HTTP Endpoints
Once mounted, the following endpoints are available:
GET /callback- OAuth callback handlerPOST /webhooks/:provider/:event- Webhook receiverGET /providers- List available providersGET /connections- List user connectionsPOST /connections/auth- Get OAuth authorization URLPOST /connections/disconnect- Disconnect a connectionGET /workflows- List workflowsGET /metrics- Get execution metrics
Documentation
Examples
See the examples/ directory for:
- Basic usage
- Complete workflows
- Express server integration
- Testing examples
Development
# Install dependencies
npm install
# Build
npm run build
# Test
npm test
# Development mode
npm run devLicense
Apache-2.0
