Framework
Seed an Express + Postgres API with MockHero
Script
// scripts/seed.mjs
import pg from "pg";
const client = new pg.Client({ connectionString: process.env.DATABASE_URL });
await client.connect();
const sql = await fetch("https://api.mockhero.dev/api/v1/generate", {
method: "POST",
headers: { "x-api-key": process.env.MOCKHERO_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
format: "sql",
dialect: "postgresql",
tables: [
{ name: "users", count: 100, fields: [
{ name: "id", type: "uuid" },
{ name: "email", type: "email" }
]},
{ name: "orders", count: 500, fields: [
{ name: "id", type: "uuid" },
{ name: "user_id", type: "ref", ref: "users.id" },
{ name: "total", type: "price" }
]}
]
})
}).then(r => r.text());
await client.query(sql);
await client.end();
Get Started
M
MockHero Team
Guides and tutorials for generating realistic test data with the MockHero API.
Start generating test data for free
1,000 rows/month on the free tier. No credit card required.
Get Your API Key