Skip to content

Write the app. Alpyne runs it.

Declare your data, logic and permissions in TypeScript and skip the backend plumbing. Compose Apps into bigger applications. Open source.

This is a whole App:

examples/hello-alpyne.ts
import type { AppSpec } from '@alpynehq/alpyne-types/builder';
interface ApproveInput {
readonly id: string;
}
export const leaveApp: AppSpec = (app) => {
app.configure('leave');
const leaveRequest = app.addTemplate('leaveRequest');
leaveRequest.addProperty('reason', 'string');
const pending = leaveRequest.addState('pending').setDefault();
const approved = leaveRequest.addState('approved');
pending.addTransition('approve', approved);
const approve = app.addMutation('approve', async (input: ApproveInput, current, ctx) => {
const item = await current.templates.leaveRequest.getItem(input.id);
if (item === undefined || item.state?.value !== 'pending') throw new Error('Leave request is not pending');
const updated = await item.state.transitions.approve.execute({});
ctx.log(`${updated.id} is now ${updated.state?.value}`); // => "<id> is now approved"
});
approve.input.addProperty('id', 'id').mandatory();
approve.output.void();
};