Skip to content

Commit

Permalink
refactor: update entry point to src/index.ts
Browse files Browse the repository at this point in the history
Renamed src/worker.ts to src/index.ts and updated relevant references.
  • Loading branch information
gentlementlegen committed Oct 14, 2024
1 parent 51fe242 commit 12aeec2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "command-query-user",
"version": "1.0.0",
"description": "Queries a user and retrieves its related information, such as the wallet, the label access control, or the current XP.",
"main": "src/worker.ts",
"main": "src/index.ts",
"author": "Ubiquity DAO",
"license": "MIT",
"engines": {
Expand Down
13 changes: 9 additions & 4 deletions src/worker.ts → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createClient } from "@supabase/supabase-js";
import { createPlugin } from "@ubiquity-os/ubiquity-os-kernel";
import { ExecutionContext } from "hono";
import manifest from "../manifest.json";
import { createAdapters } from "./adapters";
import { run } from "./run";
Expand All @@ -8,13 +9,17 @@ import { Database } from "./types/database";
import { Env } from "./types/env";
import { PluginSettings } from "./types/plugin-input";

export default createPlugin<PluginSettings, Env, SupportedEvents>(
const pluginPromise = createPlugin<PluginSettings, Env, SupportedEvents>(
(context) => {
const supabase = createClient<Database>(context.env.SUPABASE_URL, context.env.SUPABASE_KEY);
return run({ ...context, adapters: createAdapters(supabase, context) });
},
// @ts-expect-error strings cannot be assigned to events
manifest
).then((app) => ({
fetch: app.fetch,
}));
);

export default {
async fetch(request: Request, env: Env, context: ExecutionContext) {
return (await pluginPromise).fetch(request, env, context);
},
};
2 changes: 1 addition & 1 deletion wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "command-query-user"
main = "src/worker.ts"
main = "src/index.ts"
compatibility_date = "2024-09-24"
compatibility_flags = [ "nodejs_compat" ]
[env.dev]
Expand Down

0 comments on commit 12aeec2

Please sign in to comment.