Skip to content

Commit

Permalink
update: 新規ユーザー追加時にWebHookを送信するようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
watasuke102 committed Jan 16, 2024
1 parent a8c89ca commit f1ee9f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions sample-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export const env: Env = {
CATEGORY_ADD: '',
TAG_REQUEST_ADD: '',
UPDATE: '',
NEW_USER: '',
},
};
5 changes: 5 additions & 0 deletions src/app/api/session/login/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {eq} from 'drizzle-orm';
import {getIronSession} from 'iron-session';
import {Session} from '@mytypes/Session';
import {env} from 'env';
import {webhook} from '../../webhook';

export type LoginData = {
uid: string;
Expand All @@ -29,6 +30,10 @@ export async function POST(req: Request): Promise<Response> {
return Response.json({message: '許可されていないメールアドレス形式です'});
}
await db.insert(users).values({...data});
webhook(env.WEBHOOK.NEW_USER, '新規ユーザー', [
{name: 'email', value: data.email},
{name: 'uid', value: data.uid},
]);
user = {
...data,
is_admin: false,
Expand Down
1 change: 1 addition & 0 deletions src/types/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export type Env = {
CATEGORY_ADD: string;
TAG_REQUEST_ADD: string;
UPDATE: string;
NEW_USER: string;
};
};

0 comments on commit f1ee9f1

Please sign in to comment.