--- .env.sample
+++ .env.sample
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 |
GITHUB_CLIENT_ID=b |
9 | 9 |
GITHUB_CLIENT_SECRET=f |
10 | 10 |
SLACK_HOOK_URL=slack |
11 |
+WEBHOOK_DISCORD=discord |
|
11 | 12 |
SENTRY_URL=sentry |
12 | 13 |
|
13 | 14 |
BASE_URL=http://localhost:3000 |
--- config_/config.js
... | ... | @@ -1,16 +0,0 @@ |
1 | -require('dotenv').config() | |
2 | -module.exports = { | |
3 | - /* | |
4 | - * This file contains the configurations information of Twitter login app. | |
5 | - * It consists of Twitter app information, database information. | |
6 | - */ | |
7 | - | |
8 | - facebook_api_key: process.env.FACEBOOK_API_KEY, | |
9 | - facebook_api_secret: process.env.FACEBOOK_API_SECRET, | |
10 | - callback_url: `${process.env.BASE_URL}/auth/facebook/callback`, | |
11 | - use_database: false, | |
12 | - host: 'localhost', | |
13 | - username: process.env.DB_USER, | |
14 | - password: process.env.DB_PASS, | |
15 | - database: process.env.DB_NAME, | |
16 | -} |
+++ lib/notify.js
... | ... | @@ -0,0 +1,23 @@ |
1 | +const axios = require('axios') | |
2 | +require('dotenv').config() | |
3 | + | |
4 | +function notify(message) { | |
5 | + axios({ | |
6 | + method: 'post', | |
7 | + url: process.env.WEBHOOK_DISCORD, | |
8 | + headers: { | |
9 | + 'Content-Type': 'application/json', | |
10 | + }, | |
11 | + data: JSON.stringify({ | |
12 | + content: '=====\n' + message, | |
13 | + }), | |
14 | + }) | |
15 | + .then((response) => { | |
16 | + console.log(response.status, response.headers.date) | |
17 | + }) | |
18 | + .catch((error) => { | |
19 | + console.error(error) | |
20 | + }) | |
21 | +} | |
22 | + | |
23 | +module.exports = notify |
--- lib/user.js
+++ lib/user.js
... | ... | @@ -1,4 +1,5 @@ |
1 | 1 |
const { sequelize, Model, DataTypes } = require('../lib/db') |
2 |
+const notify = require('../lib/notify') |
|
2 | 3 |
|
3 | 4 |
class User extends Model {} |
4 | 5 |
User.init( |
... | ... | @@ -13,6 +14,7 @@ |
13 | 14 |
async function create(data) { |
14 | 15 |
await sequelize.sync() |
15 | 16 |
const row = await User.create(data) |
17 |
+ notify(row.dataValues.email + ' 님이 가입했습니다.') |
|
16 | 18 |
return row |
17 | 19 |
} |
18 | 20 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?