arri
TypeScript icon, indicating that this package has built-in type declarations

0.49.1 • Public • Published

Arri CLI

Command line interface for ARRI-RPC

Usage with @arrirpc/server

For full details visit the server docs

1) Create an arri.config.ts

import { defineConfig } from "arri";

export default defineConfig({
    srcDir: "src",
    entry: "app.ts",
    port: 3000,
    generators: [
        // client generators go here (can be imported from arri)
    ],
});

2) Develop your server

arri dev
arri build

Generate Clients Without an Arri Server

1) Create an App Definition

// app-definition.ts
import { createAppDefinition } from "arri";
import { a } from "@arrirpc/schema";

export default createAppDefinition({
    procedures: {
        sayHello: {
            transport: "http",
            method: "post",
            path: "/say-hello",
            params: a.object({
                name: a.string(),
            }),
            response: a.object({
                message: a.string(),
            }),
        },
    },
});

2) Create an arri.config.ts

// arri.config.ts
import {
    defineConfig,
    typescriptClientGenerator,
    dartClientGenerator,
    kotlinClientGenerator,
} from "arri";

export default defineConfig({
    generators: [
        typescriptClientGenerator({
            // options
        }),
        dartClientGenerator({
            // options
        }),
        kotlinClientGenerator({
            // options
        }),
    ],
});

3) Run codegen command

arri codegen ./app-definition.ts

Now you can use the generated clients in your application code

// typescript
await client.sayHello({
    name: "John Doe",
});
// dart
await client.sayHello(
    SayHelloParams(
        name: "John Doe",
    ),
);
// kotlin
client.sayHello(
    SayHelloParams(
        name = "John Doe"
    )
)

Readme

Keywords

none

Package Sidebar

Install

npm i arri

Weekly Downloads

226

Version

0.49.1

License

MIT

Unpacked Size

84 kB

Total Files

15

Last publish

Collaborators

  • joshmossas