canary/canary.node.tsx
2025-08-16 14:02:39 +03:00

60 lines
No EOL
1.4 KiB
TypeScript

/** @jsx $mol_jsx */
namespace $ {
$hyoo_crus_yard.masters = [
"http://localhost:9090/"
// "http://127.0.0.1:9090/"
// $mol_dom_context.document.location.origin +'/',
]
// используем hyoo_crus_app_node чтобы сразу иметь крас ноду
export class $hd_canary extends $hyoo_crus_app_node {
@ $mol_mem
_stat_update() {
const home = this.$.$hyoo_crus_glob.home( $hd_canary_app_home )
for (const site of home.Sites(null)!.remote_list()) {
site.tick()
}
}
@ $mol_memo.method
sites() {
return new $hd_canary_sites
}
}
export class $hd_canary_sites extends $mol_rest_resource {
POST( msg: $mol_rest_message ) {
const {domain} = JSON.parse(msg.text())
const home = this.$.$hyoo_crus_glob.home( $hd_canary_app_home )
const new_site = home.Sites(null)!.make({ '': $hyoo_crus_rank_rule })
new_site.domain(null)!.val(domain)
msg.reply( new_site.land().ref().description! )
}
// TODO
DELETE( msg: $mol_rest_message ): void {
// const {ref} = JSON.parse(msg.text())
// const home = this.$.$hyoo_crus_glob.home( $hd_canary_app_home )
// const current_all = home.Sites(null)!.items_vary()
// console.log({current_all})
// const new_all = current_all.filter(item => item?.toString() != ref)
// home.Sites(null)!.splice(new_all)
// msg.reply( "ok" )
}
}
}
$.$hd_canary.serve()
/*
npm start
+ hd/canary port=9090
*/