Skip to content

Commit

Permalink
version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Jul 27, 2024
1 parent a242056 commit c50590f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 90 deletions.
27 changes: 17 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slack-cloudflare-workers",
"version": "0.14.3",
"version": "1.0.0",
"description": "Slack app development framework for Cloudflare Workers",
"main": "dist/index.js",
"scripts": {
Expand All @@ -27,7 +27,8 @@
},
"homepage": "https://github.com/seratch/slack-cloudflare-workers#readme",
"dependencies": {
"slack-edge": "^0.14.4"
"@cloudflare/workers-types": "^4.20240725.0",
"slack-edge": "^1.0.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "slack-edge";

export * from "./kv";
export * from "./kv-installation-store";
export * from "./kv-state-store";
17 changes: 10 additions & 7 deletions src/kv-installation-store.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { KVNamespace, KVNamespaceListResult } from "@cloudflare/workers-types";
import {
AuthTestResponse,
Authorize,
Expand All @@ -9,14 +10,13 @@ import {
SlackOAuthEnv,
TokenRotator,
} from "slack-edge";
import { KV } from "./kv";

export class KVInstallationStore<E extends SlackOAuthEnv> implements InstallationStore<E> {
#env: E;
#storage: KV;
#storage: KVNamespace;
#tokenRotator: TokenRotator;

constructor(env: E, namespace: KV) {
constructor(env: E, namespace: KVNamespace) {
this.#env = env;
this.#storage = namespace;
this.#tokenRotator = new TokenRotator({
Expand Down Expand Up @@ -62,10 +62,13 @@ export class KVInstallationStore<E extends SlackOAuthEnv> implements Installatio
var keys: string[] = [];
const first = await this.#storage.list({ prefix });
keys = keys.concat(first.keys.map((k) => k.name));
var cursor: string | undefined = first.cursor;
while (cursor) {
const response = await this.#storage.list({ prefix, cursor });
keys = keys.concat(response.keys.map((k) => k.name));
if (!first.list_complete) {
var cursor: string | undefined = first.cursor;
while (cursor) {
const response: KVNamespaceListResult<unknown, string> = await this.#storage.list({ prefix, cursor });
keys = keys.concat(response.keys.map((k) => k.name));
cursor = response.list_complete ? undefined : response.cursor;
}
}
for (const key of keys) {
await this.#storage.delete(key);
Expand Down
6 changes: 3 additions & 3 deletions src/kv-state-store.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { KV } from "./kv";
import { StateStore } from "slack-edge";
import { KVNamespace } from "@cloudflare/workers-types";

export class KVStateStore implements StateStore {
#storage: KV;
#storage: KVNamespace;

constructor(namespace: KV) {
constructor(namespace: KVNamespace) {
this.#storage = namespace;
}

Expand Down
67 changes: 0 additions & 67 deletions src/kv.ts

This file was deleted.

0 comments on commit c50590f

Please sign in to comment.