https://github.com/predetermined/hag
Something
https://github.com/predetermined/hag
Last synced: 30 days ago
JSON representation
Something
- Host: GitHub
- URL: https://github.com/predetermined/hag
- Owner: predetermined
- License: lgpl-3.0
- Created: 2020-04-23T20:04:56.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-23T20:15:27.000Z (about 6 years ago)
- Last Synced: 2025-12-26T04:49:36.833Z (6 months ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 }}`;
}
}
```