Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 885 Bytes

README.md

File metadata and controls

40 lines (29 loc) · 885 Bytes

@opennetwork/environment

Cross platform JavaScript environment

nycrc config on GitHub

Usage

import {run, addEventListener, fetch} from "@opennetwork/environment"; 
import {Response} from "@opennetwork/http-representation";

addEventListener("install", async () => {
   console.log("Setup something!"); 
});

addEventListener("configure", async () => {
    console.log("Updated configuration for something!");
});

addEventListener("fetch", async (event) => {
    event.respondWith(new Response("Not Found", {
        status: 404
    }))
});

addEventListener("execute", async () => {
    const response = await fetch("/something");
    console.log("Response status: ", response.status);
    console.log("Done something!");
});

await run({
    /* config here */
})