Upload 14 files
Browse files- .editorconfig +9 -0
- .env +8 -0
- .env+ +8 -0
- .env- +31 -0
- .eslintrc.json +23 -0
- .htaccess +1 -0
- .prettierrc +16 -0
- dirname.js +6 -0
- package-lock.json +0 -0
- package.json +52 -0
- response.js +13 -0
- routes.js +42 -0
- server.js +35 -0
- yarn.lock +0 -0
.editorconfig
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
root = true
|
2 |
+
|
3 |
+
[*]
|
4 |
+
charset = utf-8
|
5 |
+
end_of_line = lf
|
6 |
+
indent_size = 4
|
7 |
+
indent_style = space
|
8 |
+
insert_final_newline = true
|
9 |
+
trim_trailing_whitespace = true
|
.env
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PORT=8000
|
2 |
+
DBHOST=127.0.0.1
|
3 |
+
DBNAME=u687661449_ham2
|
4 |
+
DBUSER=u687661449_ham2
|
5 |
+
DBPASS=Password@123
|
6 |
+
DBPORT=3306
|
7 |
+
JWTKEY=NCRUp5hKovUAcZd9OwIw0BCKmjZj9JxpNCRUp5hKovUAcZd9OwIw0BCKmjZj9JxpNCRUp5hKovUAcZd9OwIw0BCKmjZj9Jxp
|
8 |
+
URI=http://localhost:8000
|
.env+
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PORT=8000
|
2 |
+
DBHOST=127.0.0.1
|
3 |
+
DBNAME=u687661449_whatham
|
4 |
+
DBUSER=u687661449_whatham
|
5 |
+
DBPASS=Password@123
|
6 |
+
DBPORT=3306
|
7 |
+
JWTKEY=NCRUp5hKovUAcZd9OwIw0BCKmjZj9JxpNCRUp5hKovUAcZd9OwIw0BCKmjZj9JxpNCRUp5hKovUAcZd9OwIw0BCKmjZj9Jxp
|
8 |
+
URI=http://localhost:8000
|
.env-
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PORT=8001
|
2 |
+
DBHOST=127.0.0.1
|
3 |
+
DBNAME=u687661449_dallham2
|
4 |
+
DBUSER=u687661449_dallham2
|
5 |
+
DBPASS=Password@123
|
6 |
+
DBPORT=3306
|
7 |
+
JWTKEY=NCRUp5hKovUAcZd9OwIw0BCKmjZj9JxpNCRUp5hKovUAcZd9OwIw0BCKmjZj9JxpNCRUp5hKovUAcZd9OwIw0BCKmjZj9Jyp
|
8 |
+
OPENAIMODEL=gpt-3.5-turbo-16k-0613
|
9 |
+
URI=http://localhost:8001/whatham
|
10 |
+
|
11 |
+
|
12 |
+
# Whisper API
|
13 |
+
|
14 |
+
# API Key
|
15 |
+
WHISPER_API_KEY=ZCCBLCZ8IHLQ9GL2FUYHNV3ZZBEFNG7P
|
16 |
+
|
17 |
+
# You can use Whisper API for voice transcription
|
18 |
+
WHISPER_API_URL=https://transcribe.whisperapi.com
|
19 |
+
|
20 |
+
# Defines if the bot should recognize and transcribe your voice messages
|
21 |
+
TRANSCRIPTION_ENABLED=true
|
22 |
+
|
23 |
+
# Defines if the bot should use the local or remote transcription service
|
24 |
+
# "local" = You need to have "whisper" installed on your machine
|
25 |
+
# "openai" = It will use Open AI's transcription API with whisper-1 model
|
26 |
+
# "speech-api" = It will use our Speech API to transcribe your voice messages
|
27 |
+
# "whisper-api" = It will use whisper's API to transcribe your voice messages
|
28 |
+
TRANSCRIPTION_MODE=whisper-api
|
29 |
+
|
30 |
+
# Define the language of transcription, depends on transcriber it might auto-detect if not given
|
31 |
+
TRANSCRIPTION_LANGUAGE=Portuguese
|
.eslintrc.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"env": {
|
3 |
+
"node": true
|
4 |
+
},
|
5 |
+
"extends": ["xo", "prettier"],
|
6 |
+
"parserOptions": {
|
7 |
+
"ecmaVersion": 2020,
|
8 |
+
"sourceType": "module"
|
9 |
+
},
|
10 |
+
"rules": {
|
11 |
+
"prettier/prettier": "error",
|
12 |
+
"one-var": "off",
|
13 |
+
"max-params": ["error", 5],
|
14 |
+
"arrow-body-style": ["error", "always"],
|
15 |
+
"radix": "off",
|
16 |
+
"no-unused-expressions": ["error", { "allowTernary": true }],
|
17 |
+
"curly": "error",
|
18 |
+
"new-cap": "off",
|
19 |
+
"no-return-assign": "off",
|
20 |
+
"no-await-in-loop": "off"
|
21 |
+
},
|
22 |
+
"plugins": ["prettier"]
|
23 |
+
}
|
.htaccess
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
# Please fill in the URLrewrite rules or custom Apache config here
|
.prettierrc
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"printWidth": 120,
|
3 |
+
"tabWidth": 4,
|
4 |
+
"useTabs": false,
|
5 |
+
"endOfLine": "lf",
|
6 |
+
"semi": false,
|
7 |
+
"singleQuote": true,
|
8 |
+
"overrides": [
|
9 |
+
{
|
10 |
+
"files": "*.json",
|
11 |
+
"options": {
|
12 |
+
"tabWidth": 2
|
13 |
+
}
|
14 |
+
}
|
15 |
+
]
|
16 |
+
}
|
dirname.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { dirname } from 'path'
|
2 |
+
import { fileURLToPath } from 'url'
|
3 |
+
|
4 |
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
5 |
+
|
6 |
+
export default __dirname
|
package-lock.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
package.json
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "whatsham-api",
|
3 |
+
"description": "whatsham backend api by hamidsaifi.com",
|
4 |
+
"private": true,
|
5 |
+
"main": "server.js",
|
6 |
+
"type": "module",
|
7 |
+
"scripts": {
|
8 |
+
"start": "node ."
|
9 |
+
},
|
10 |
+
"author": "hamidsaifi.com",
|
11 |
+
"engines": {
|
12 |
+
"node": ">=14.5.0"
|
13 |
+
},
|
14 |
+
"dependencies": {
|
15 |
+
"@adiwajshing/keyed-db": "^0.2.4",
|
16 |
+
"@hapi/boom": "^10.0.1",
|
17 |
+
"@whiskeysockets/baileys": "^6.2.1",
|
18 |
+
"axios": "^1.4.0",
|
19 |
+
"bcrypt": "^5.1.0",
|
20 |
+
"cheerio": "^1.0.0-rc.12",
|
21 |
+
"cors": "^2.8.5",
|
22 |
+
"crypto": "^1.0.1",
|
23 |
+
"csvtojson": "^2.0.10",
|
24 |
+
"dotenv": "^16.0.0",
|
25 |
+
"exceljs": "^4.3.0",
|
26 |
+
"express": "^4.17.2",
|
27 |
+
"express-fileupload": "^1.4.0",
|
28 |
+
"express-validator": "^6.14.0",
|
29 |
+
"extract-zip": "^2.0.1",
|
30 |
+
"got": "^12.6.0",
|
31 |
+
"jsonwebtoken": "^9.0.0",
|
32 |
+
"libphonenumber-js": "^1.10.30",
|
33 |
+
"mime-types": "^2.1.35",
|
34 |
+
"moment": "^2.29.4",
|
35 |
+
"mysql": "^2.18.1",
|
36 |
+
"mysql-import": "^5.0.26",
|
37 |
+
"node-cleanup": "^2.1.2",
|
38 |
+
"node-fetch": "^2.6.9",
|
39 |
+
"nodemailer": "^6.9.1",
|
40 |
+
"pino": "^7.10.0",
|
41 |
+
"qrcode": "^1.5.0",
|
42 |
+
"qrcode-terminal": "^0.12.0",
|
43 |
+
"randomstring": "^1.2.3"
|
44 |
+
},
|
45 |
+
"devDependencies": {
|
46 |
+
"eslint": "^8.5.0",
|
47 |
+
"eslint-config-prettier": "^8.3.0",
|
48 |
+
"eslint-config-xo": "^0.39.0",
|
49 |
+
"eslint-plugin-prettier": "^4.0.0",
|
50 |
+
"prettier": "^2.5.1"
|
51 |
+
}
|
52 |
+
}
|
response.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const response = (res, statusCode = 200, success = false, message = '', data = {}, contacts) => {
|
2 |
+
res.status(statusCode)
|
3 |
+
res.json({
|
4 |
+
success,
|
5 |
+
message,
|
6 |
+
data,
|
7 |
+
contacts
|
8 |
+
})
|
9 |
+
|
10 |
+
res.end()
|
11 |
+
}
|
12 |
+
|
13 |
+
export default response
|
routes.js
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Router } from 'express'
|
2 |
+
import sessionsRoute from './routes/sessionsRoute.js'
|
3 |
+
import chatsRoute from './routes/chatsRoute.js'
|
4 |
+
import groupsRoute from './routes/groupsRoute.js'
|
5 |
+
import userRoute from './routes/userRoute.js'
|
6 |
+
import response from './response.js'
|
7 |
+
import adminRoute from './routes/adminRoute.js'
|
8 |
+
import planRoute from './routes/planRoute.js'
|
9 |
+
import pingRoute from './routes/pingRoute.js'
|
10 |
+
import botRoute from './routes/botRoute.js'
|
11 |
+
import templetRoute from './routes/templetRoute.js'
|
12 |
+
import sendMessageRoute from './routes/sendMessageRoute.js'
|
13 |
+
import phonebookRoute from './routes/phonebookRoute.js'
|
14 |
+
import campaignRoute from './routes/campaignRoute.js'
|
15 |
+
import webRouts from './routes/webRouts.js'
|
16 |
+
|
17 |
+
const router = Router()
|
18 |
+
|
19 |
+
router.use('/sessions', sessionsRoute)
|
20 |
+
router.use('/chats', chatsRoute)
|
21 |
+
router.use('/groups', groupsRoute)
|
22 |
+
router.use('/user', userRoute)
|
23 |
+
router.use('/admin', adminRoute)
|
24 |
+
router.use('/plan', planRoute)
|
25 |
+
router.use('/ping', pingRoute)
|
26 |
+
router.use('/bot', botRoute)
|
27 |
+
|
28 |
+
router.use('/send-message', sendMessageRoute)
|
29 |
+
|
30 |
+
router.use('/templet', templetRoute)
|
31 |
+
|
32 |
+
router.use('/phonebook', phonebookRoute)
|
33 |
+
|
34 |
+
router.use('/web', webRouts)
|
35 |
+
|
36 |
+
router.use('/campaign', campaignRoute)
|
37 |
+
|
38 |
+
router.all('*', (req, res) => {
|
39 |
+
response(res, 404, false, 'The requested url cannot be found.')
|
40 |
+
})
|
41 |
+
|
42 |
+
export default router
|
server.js
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import 'dotenv/config'
|
2 |
+
import express from 'express'
|
3 |
+
import nodeCleanup from 'node-cleanup'
|
4 |
+
import fileUpload from 'express-fileupload'
|
5 |
+
import routes from './routes.js'
|
6 |
+
import { init, cleanup } from './middlewares/req.js'
|
7 |
+
import cors from 'cors'
|
8 |
+
|
9 |
+
const app = express()
|
10 |
+
|
11 |
+
app.use(express.urlencoded({ extended: true }))
|
12 |
+
app.use(cors())
|
13 |
+
app.use(express.json())
|
14 |
+
app.use(fileUpload())
|
15 |
+
app.use('/api', routes)
|
16 |
+
|
17 |
+
// linking client
|
18 |
+
import path from 'path';
|
19 |
+
|
20 |
+
const currentDir = process.cwd();
|
21 |
+
|
22 |
+
app.use(express.static(path.resolve(currentDir, "./client/public")));
|
23 |
+
|
24 |
+
app.get("*", function (request, response) {
|
25 |
+
response.sendFile(path.resolve(currentDir, "./client/public", "index.html"));
|
26 |
+
});
|
27 |
+
|
28 |
+
app.listen(process.env.PORT || 3010, () => {
|
29 |
+
init()
|
30 |
+
console.log(`Whatsham server is runnin gon port ${process.env.PORT}`)
|
31 |
+
})
|
32 |
+
|
33 |
+
nodeCleanup(cleanup)
|
34 |
+
|
35 |
+
export default app
|
yarn.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|