Claviz / drayman

Server-side component framework.
https://drayman.io
MIT License
76 stars 4 forks source link
drayman framework nodejs typescript

Drayman

Drayman is a server-side component framework. [Docs](https://drayman.io) · [Blog](https://drayman.io/blog) · [Changelog](https://github.com/Claviz/drayman/releases) · [Join Discord](https://discord.gg/5GYZTvUSxV) · [X](https://x.com/draymanio) ![Version](https://img.shields.io/github/v/release/claviz/drayman) ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/claviz/drayman/config.yml)

✨ Features

📸 Snapshot

Do you want to create a web application that, for example, allows the user to select a file from the file system and view it's contents? With Drayman it would be a single script:

import { promises as fs } from "fs";

export const component: DraymanComponent = async ({ forceUpdate }) => {
  const files = (await fs.readdir("./")).filter((x) => x.includes("."));
  let selectedFile;

  return async () => {
    return (
      <>
        <p>Select a file to view it directly from file system</p>
        <select
          onchange={async ({ value }) => {
            selectedFile = value;
            await forceUpdate();
          }}
        >
          {files.map((fileName) => (
            <option value={fileName}>{fileName}</option>
          ))}
        </select>
        <br />
        {selectedFile && <pre>{await fs.readFile(selectedFile, "utf-8")}</pre>}
      </>
    );
  };
};