An open API service indexing awesome lists of open source software.

https://github.com/predetermined/hag

Something
https://github.com/predetermined/hag

Last synced: 30 days ago
JSON representation

Something

Awesome Lists containing this project

README

          

# Hag
**Don't use this project. There are uncountable bugs and I'm building this project only while I create other projects.**

## Example server start
```typescript
import { Hag } from "hag";
import Hello from "./pages/Hello.ts";

const app = new Hag();
app.register("/", Hello);

app.listen(3000);
```

## Pages
### Example page
```typescript
export default class Hello {
private world: string = "World";

get template() {
return `Hello, {{ this.world }}`;
}
}

// Rendered output would be `Hello, World`
```

### Page exposures
Page exposures are executed client-side.
I don't really like how I'm handling it right now.
It's getting changed sometime.
```typescript
export default class Hello {
get exposures() {
return {
logClick() {
console.log("clicked");
}
}
}

get template() {
return `Log click`;
}
}
```

### Page endpoints
The template is getting rerendered & sent to the automatically.
Endpoint URLs are build like: `[page]/api/[endpoint]`
```typescript
export default class Hello {
private world: string = "World";

get endpoints() {
return {
GET: {
changeWorldText() {
this.world = "stay home.";
}
}
}
}

get exposures() {
return {
changoMango() {
fetch("api/changeWorldText");
}
}
}

get template() {
return `Change the world Hello, {{ this.world }}`;
}
}
```