Skip to content

Commit

Permalink
version 0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Jul 23, 2024
1 parent 3f89519 commit 50ea84d
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 120 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ docs/
scripts/
tmp/
.github/
biome.json
28 changes: 28 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"attributePosition": "auto",
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 140,
"lineEnding": "lf"
},
"javascript": {
"formatter": {
"arrowParentheses": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"semicolons": "always",
"trailingCommas": "all"
}
},
"json": {
"formatter": {
"trailingCommas": "none"
}
}
}
6 changes: 1 addition & 5 deletions examples/oauth-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ type Env = SlackOAuthAndOIDCEnv & {
};

export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext,
): Promise<Response> {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const app = new SlackOAuthApp({
env,
installationStore: new KVInstallationStore(env, env.SLACK_INSTALLATIONS),
Expand Down
26 changes: 6 additions & 20 deletions examples/simple-app/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {
isPostedMessageEvent,
} from "../../../src/index";

export const appMention: EventLazyHandler<"app_mention"> = async ({
context,
}) => {
export const appMention: EventLazyHandler<"app_mention"> = async ({ context }) => {
// You can do anything time-consuing tasks here!
await context.client.chat.postMessage({
channel: context.channelId,
Expand Down Expand Up @@ -49,17 +47,13 @@ export const helloMessage: MessageEventLazyHandler = async ({ context }) => {
await context.say({ text: "Hey!" });
};

export const otherMessages: EventLazyHandler<"message"> = async ({
payload,
}) => {
export const otherMessages: EventLazyHandler<"message"> = async ({ payload }) => {
if (isPostedMessageEvent(payload)) {
console.log(`New message: ${payload.text}`);
}
};

export const asyncButtonResponse: BlockActionLazyHandler<"button"> = async ({
context,
}) => {
export const asyncButtonResponse: BlockActionLazyHandler<"button"> = async ({ context }) => {
// You can do anything time-consuing tasks here!
const { respond } = context;
const sleep = (seconds: number) => {
Expand All @@ -73,17 +67,12 @@ export const asyncButtonResponse: BlockActionLazyHandler<"button"> = async ({
};

export const ackCommand: SlashCommandAckHandler = async () => "Thanks!";
export const asyncCommandResponse: SlashCommandLazyHandler = async ({
context,
}) => {
export const asyncCommandResponse: SlashCommandLazyHandler = async ({ context }) => {
// You can do anything time-consuing tasks here!
await context.respond({ text: "What's up?" });
};

export const asyncShortcutResponse: ShortcutLazyHandler = async ({
context,
payload,
}) => {
export const asyncShortcutResponse: ShortcutLazyHandler = async ({ context, payload }) => {
// You can do anything time-consuing tasks here!
await context.client.views.open({
// trigger_id still needs to be used within 3 seconds
Expand All @@ -99,10 +88,7 @@ export const asyncShortcutResponse: ShortcutLazyHandler = async ({
});
};

export const asyncMessageShortcut: MessageShortcutLazyHandler = async ({
context,
payload,
}) => {
export const asyncMessageShortcut: MessageShortcutLazyHandler = async ({ context, payload }) => {
// You can do anything time-consuing tasks here!
await context.client.views.open({
// trigger_id still needs to be used within 3 seconds
Expand Down
12 changes: 2 additions & 10 deletions examples/simple-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import {
SlackApp,
SlackEdgeAppEnv,
isPostedMessageEvent,
} from "../../../src/index";
import { SlackApp, SlackEdgeAppEnv, isPostedMessageEvent } from "../../../src/index";

export default {
async fetch(
request: Request,
env: SlackEdgeAppEnv,
ctx: ExecutionContext,
): Promise<Response> {
async fetch(request: Request, env: SlackEdgeAppEnv, ctx: ExecutionContext): Promise<Response> {
const app = new SlackApp({ env })
// when the pattern matches, the framework automatically acknowledges the request
.event("app_mention", async ({ context }) => {
Expand Down
6 changes: 1 addition & 5 deletions examples/simple-app/src/structured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ import {
} from "./handlers";

export default {
async fetch(
request: Request,
env: SlackEdgeAppEnv,
ctx: ExecutionContext,
): Promise<Response> {
async fetch(request: Request, env: SlackEdgeAppEnv, ctx: ExecutionContext): Promise<Response> {
const app = new SlackApp({ env })
// when the pattern matches, the framework automatically acknowledges the request
.event("app_mention", appMention)
Expand Down
186 changes: 167 additions & 19 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "slack-cloudflare-workers",
"version": "0.13.4",
"version": "0.14.0",
"description": "Slack app development framework for Cloudflare Workers",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"build:clean": "rm -rf ./dist && tsc",
"format": "npx prettier --write src/ examples/simple-app/src/ examples/oauth-app/src/"
"format": "npx @biomejs/biome format --write src/ examples/simple-app/src/ examples/oauth-app/src/"
},
"repository": {
"type": "git",
Expand All @@ -27,10 +27,10 @@
},
"homepage": "https://github.com/seratch/slack-cloudflare-workers#readme",
"dependencies": {
"slack-edge": "^0.13.4"
"slack-edge": "^0.14.0"
},
"devDependencies": {
"prettier": "^3.3.2",
"typescript": "^5.5.3"
"@biomejs/biome": "^1.8.3",
"typescript": "^5.5.4"
}
}
2 changes: 1 addition & 1 deletion scripts/upgrade-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
npm i slack-edge@latest
npm i --save-dev prettier@latest typescript@latest
npm i --save-dev @biomejs/biome@latest typescript@latest
Loading

0 comments on commit 50ea84d

Please sign in to comment.