-
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.
[+Add] Adding readme [+Add] Adding helmet [*Feat] Fixing some issue with main services [-Delete] Delete logs
- Loading branch information
1 parent
8e02d9a
commit 7ed05f6
Showing
17 changed files
with
449 additions
and
158 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,57 @@ | ||
# Messenger | ||
A Simple Messenger | ||
## A Simple Facebook Bot Messenger | ||
|
||
<img alt="Sample demo of The Messenger Bot" src="./example.gif" width="270" height="480"> | ||
|
||
### Installation: | ||
|
||
- Install required packages | ||
```shell script | ||
npm i | ||
``` | ||
- Copy and modify .env file for Environment Variables | ||
```shell script | ||
cp .env.example .env | ||
``` | ||
|
||
### Configuration | ||
- Put the Access Token in the `MESSENGER_BOT_ACCESS_TOKEN` in `.env` file | ||
- Put the Verify Token in the `MESSENGER_BOT_VERIFY_TOKEN` in `.env` file | ||
|
||
### Usage | ||
|
||
Run the project | ||
```shell script | ||
npm start | ||
``` | ||
|
||
For the development perposes | ||
```shell script | ||
npm i -g nodemon | ||
npm run dev | ||
``` | ||
|
||
For the deployment perposes | ||
```shell script | ||
docker-compose up -d | ||
``` | ||
|
||
|
||
### Tests | ||
|
||
Run the tests | ||
```shell script | ||
npm test | ||
``` | ||
|
||
For coverage run | ||
```shell script | ||
npm run coverage | ||
``` | ||
|
||
### Documents | ||
|
||
For generate and serve documents | ||
```shell script | ||
npm run doc | ||
``` |
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,53 +1,40 @@ | ||
class Model { | ||
|
||
constructor(client){ | ||
|
||
this.cache = {}; | ||
|
||
this.client = client; | ||
this.expireTime = 60*60*2;//2h | ||
|
||
} | ||
|
||
async readFromCache(key){ | ||
|
||
// const data = JSON.stringify(value); | ||
// return this.client.getAsync(key,data,'EX',this.expireTime); | ||
|
||
return new Promise(( | ||
(resolve)=>{ | ||
|
||
let result; | ||
|
||
if(!this.cache[key]){ | ||
try{ | ||
result = await this.client.getAsync(key,data,'EX',this.expireTime); | ||
}catch(error){ | ||
throw new Error("Couldn't read from Cache"); | ||
} | ||
} else { | ||
result = this.cache[key]; | ||
} | ||
|
||
resolve(result) | ||
|
||
}, | ||
(reject)=>{ | ||
|
||
} | ||
)) | ||
|
||
} | ||
|
||
updateCache(key,value){ | ||
|
||
this.data[key] = value; | ||
const data = JSON.stringify(value); | ||
return this.client.setAsync(key,data,'EX',this.expireTime); | ||
|
||
} | ||
|
||
|
||
constructor(client) { | ||
this.cache = {}; | ||
|
||
this.client = client; | ||
this.expireTime = 60 * 60 * 2; //2h | ||
} | ||
|
||
async readFromCache(key) { | ||
// const data = JSON.stringify(value); | ||
// return this.client.getAsync(key,data,'EX',this.expireTime); | ||
|
||
return new Promise( | ||
((resolve) => { | ||
let result; | ||
|
||
if (!this.cache[key]) { | ||
try { | ||
result = this.client.get(key); | ||
} catch (error) { | ||
throw new Error("Couldn't read from Cache"); | ||
} | ||
} else { | ||
result = this.cache[key]; | ||
} | ||
|
||
resolve(result); | ||
}, | ||
() => {}) | ||
); | ||
} | ||
|
||
updateCache(key, value) { | ||
this.data[key] = value; | ||
const data = JSON.stringify(value); | ||
return this.client.setAsync(key, data, "EX", this.expireTime); | ||
} | ||
} | ||
|
||
module.exports = Model; | ||
module.exports = Model; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ try{ | |
|
||
}catch(error){ | ||
|
||
console.log(error); | ||
//Error on Listening | ||
process.exit(0); | ||
|
||
|
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
Oops, something went wrong.