Getting started
This guide walks you through installing InfraKit and integrating it into an Express application.
Installation
Install InfraKit’s core SDK along with the modules and adapters you need:
bun install @infrakit/sdk @infrakit/modules/kv @infrakit/adapter/express expressThis installs:
- @infrakit/sdk - Core InfraKit functionality
- @infrakit/modules/kv - Key-value storage module
- @infrakit/adapter/express - Express integration
- express - Web framework
Create your first integration
Here’s how to add InfraKit to an Express application with in-memory key-value storage:
import { ExpressAdapter } from "@infrakit/adapter/express";import { KeyValueMemoryAdapter } from "@infrakit/modules/kv";import { InfraKit } from "@infrakit/sdk";import express from "express";
// Initialize InfraKit with the Key-Value moduleconst infrakit = new InfraKit({ keyValue: new KeyValueMemoryAdapter(),});
// Create the dashboard adapterconst expressAdapter = new ExpressAdapter({ baseUrl: "/dashboard", infrakit,});
// Use the keyValue client in your applicationinfrakit.keyValue.set({ key: "greeting", value: "Hello from InfraKit!" });
// Mount the dashboard endpointconst app = express();app.use("/dashboard", expressAdapter.endpoint);
app.get("/", (req, res) => { res.send("Your application is running!");});
app.listen(3000, () => { console.log("Server running on http://localhost:3000"); console.log("InfraKit Dashboard available at http://localhost:3000/dashboard");});What happens here
The code above does three things:
- Initializes InfraKit with an in-memory key-value store that you can use throughout your application
- Creates an ExpressAdapter that generates a dashboard endpoint for monitoring and managing InfraKit modules
- Mounts the dashboard at
/dashboardso you can access it athttp://localhost:3000/dashboard
Next steps
Now that InfraKit is running, you can explore the dashboard and start using the key-value module in your routes and middleware.