-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Fix] Fixing Cache service and Models
+ [Add] Adding Requests that calls Facebook APIs
- Loading branch information
1 parent
45eb099
commit 229ab89
Showing
16 changed files
with
229 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
const {Redis} = require('./redis/index.js'); | ||
let redisController = null; | ||
|
||
//Router Controller | ||
let start = (config)=>{ | ||
let redis = async ()=>{ | ||
|
||
redisController = Redis; | ||
if(redisController) { | ||
return redisController; | ||
} | ||
redisController = new Redis(); | ||
await redisController.init(); | ||
return redisController; | ||
|
||
} | ||
|
||
module.exports = { | ||
start, | ||
redis:redisController, | ||
|
||
Cacher:redis, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
'use strict'; | ||
|
||
require('dotenv').config(); | ||
const router = require('./router'); | ||
|
||
try{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function updateCache(request,response){ | ||
|
||
} | ||
|
||
module.exports = { | ||
updateCache | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
config:{ | ||
baseURL: "https://graph.facebook.com/v7.0", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
responseType: "json", | ||
}, | ||
access_token:process.env.MESSENGER_BOT_ACCESS_TOKEN | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const axios = require("axios"); | ||
const { config, access_token } = require("./config"); | ||
|
||
const client = axios.create(config); | ||
|
||
function markSeen(recipient) { | ||
const path = "/me/messages", | ||
data = { | ||
recipient: { id: recipient }, | ||
sender_action: "mark_seen", | ||
}, | ||
options = { | ||
params: { access_token }, | ||
}; | ||
|
||
return client.post(path, data, options); | ||
} | ||
|
||
function setTyping(recipient, state) { | ||
const path = "/me/messages", | ||
data = { | ||
recipient: { id: recipient }, | ||
sender_action: state ? "typing_on" : "typing_off", | ||
}, | ||
options = { | ||
params: { access_token }, | ||
}; | ||
|
||
return client.post(path, data, options); | ||
} | ||
|
||
function sendMessage(recipient, message, quckReplies) { | ||
const path = "/me/messages", | ||
data = { | ||
recipient: { id: recipient }, | ||
message: { | ||
text:message, | ||
quick_replies:quckReplies?quckReplies:undefined, | ||
}, | ||
}, | ||
options = { | ||
params: { access_token }, | ||
}; | ||
|
||
console.log(data) | ||
|
||
return client.post(path, data, options); | ||
} | ||
|
||
async function sendMessageWithSeenAndTyping(recipient, message, quckReplies) { | ||
await markSeen(recipient); | ||
await setTyping(recipient,true); | ||
await sendMessage(recipient,message,quckReplies); | ||
await setTyping(recipient,false); | ||
} | ||
|
||
module.exports = { | ||
markSeen, | ||
setTyping, | ||
sendMessage, | ||
sendMessageWithSeenAndTyping | ||
}; |
Empty file.
Empty file.
Empty file.
Oops, something went wrong.