New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hag

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hag

Something

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

import { Hag } from "hag";
import Hello from "./pages/Hello.ts";

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

app.listen(3000);

Pages

Example page

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.

export default class Hello {
    get exposures() {
        return {
            logClick() {
                console.log("clicked");
            }       
        }
    }   

    get template() {
        return `<button @onclick="logClick">Log click</button>`;
    }
}

Page endpoints

The template is getting rerendered & sent to the automatically. Endpoint URLs are build like: [page]/api/[endpoint]

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 `<button @onclick="changoMango">Change the world</button> Hello, {{ this.world }}`;
    }
}

FAQs

Package last updated on 23 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc