External Node.js Script / Server
Use @aerostack/sdk to build external scripts, CLIs, or backend services that need to talk to your Aerostack project.
When to use this?
Section titled “When to use this?”- Migration Scripts: Import data into your project.
- Reporting Tools: Fetch stats and generate reports.
- External Webhooks: Receive events from other platforms and update Aerostack.
- Microservices: Connect an existing Express/NestJS app.
Installation
Section titled “Installation”npm install @aerostack/sdkExample: Import Users Script
Section titled “Example: Import Users Script”import { AerostackClient } from '@aerostack/sdk';import csv from 'csv-parser';import fs from 'fs';
const client = new AerostackClient({ projectSlug: 'my-crm', baseUrl: 'https://api.aerostack.dev'});
async function main() { // 1. Authenticate as Admin await client.auth.login(process.env.ADMIN_EMAIL, process.env.ADMIN_PASSWORD);
// 2. Read CSV and Register Users fs.createReadStream('users.csv') .pipe(csv()) .on('data', async (row) => { try { await client.auth.register({ email: row.email, password: 'TemporaryPassword123!', name: row.name }); console.log(`✅ Registered ${row.email}`); } catch (err) { console.error(`❌ Failed ${row.email}:`, err.message); } });}
main();