Skip to content

Commit

Permalink
BREAKING CHANGE: Convert to Typescript (#1145)
Browse files Browse the repository at this point in the history
* feat: Initial migration to typescript
* fix: Fixed TokenStoreData
  • Loading branch information
icleitoncosta authored Mar 31, 2023
1 parent 397c075 commit 7fa873d
Show file tree
Hide file tree
Showing 60 changed files with 4,307 additions and 2,221 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
"node": "current"
}
}
],
[
"@babel/preset-typescript",
{
"targets": {
"node": "current"
},
"allowDeclareFields": true
}
]
],
"env": {
Expand Down
20 changes: 16 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
"es6": true,
"node": true
},
"parser": "@babel/eslint-parser",
"plugins": ["@babel"],
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "simple-import-sort", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-unused-vars": "warn"
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
}
}
11 changes: 9 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"printWidth": 120,
"singleQuote": true
"singleQuote": true,
"overrides": [
{
"files": "*.json5",
"options": {
"parser": "json"
}
}
]
}
28 changes: 25 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
"author": "kingaspx",
"license": "Apache-2.0",
"scripts": {
"build": "rimraf dist && babel src -s -D -d dist",
"build:types": "tsc",
"build:js": "rimraf dist && babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline",
"build": "npm run build:types && npm run build:js",
"changelog:last": "conventional-changelog -p angular -r 2",
"changelog:preview": "conventional-changelog -p angular -u",
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s",
"commit": "git-cz",
"dev": "nodemon -w src --exec \"babel-node src/server.js\"",
"dev": "nodemon --watch src/ --exec ts-node --esm src/server.ts -e ts",
"license:add": "license-check-and-add add",
"license:check": "license-check-and-add check",
"lint": "eslint --ext .js src",
"lint": "eslint --ext .ts src",
"prepare": "husky install",
"release": "release-it",
"start": "node ./dist/server.js",
Expand Down Expand Up @@ -55,16 +57,33 @@
"@babel/node": "^7.20.7",
"@babel/plugin-transform-runtime": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@commitlint/cli": "^17.5.1",
"@commitlint/config-conventional": "^17.4.4",
"@commitlint/cz-commitlint": "^17.5.0",
"@types/bcrypt": "^5.0.0",
"@types/buffer-to-stream": "^1.0.0",
"@types/cors": "^2.8.13",
"@types/express": "^4.17.17",
"@types/merge-deep": "^3.0.0",
"@types/mime-types": "^2.1.1",
"@types/multer": "^1.4.7",
"@types/node": "^18.11.18",
"@types/qrcode": "^1.5.0",
"@types/swagger-ui-express": "^4.1.3",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"aws-sdk": "^2.1343.0",
"commitizen": "^4.3.0",
"conventional-changelog-cli": "^2.2.2",
"crypto-js": "^4.1.1",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^33.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"license-check-and-add": "^4.0.5",
"mongoose": "^7.0.3",
Expand All @@ -76,6 +95,9 @@
"rimraf": "^4.4.1",
"shx": "^0.3.4",
"swagger-ui-dist": "^4.18.1",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"webpack-cli": "^5.0.1"
},
"peerDependencies": {
Expand Down
77 changes: 0 additions & 77 deletions src/config.json

This file was deleted.

77 changes: 77 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export default {
secretKey: 'THISISMYSECURETOKEN',
host: 'http://localhost',
port: '21465',
deviceName: 'WppConnect',
poweredBy: 'WPPConnect-Server',
startAllSession: true,
tokenStoreType: 'file',
maxListeners: 15,
customUserDataDir: './userDataDir/',
webhook: {
url: null,
autoDownload: true,
uploadS3: false,
readMessage: true,
allUnreadOnStart: false,
listenAcks: true,
onPresenceChanged: true,
onParticipantsChanged: true,
onReactionMessage: true,
onPollResponse: true,
onRevokedMessage: true,
},
archive: {
enable: false,
waitTime: 10,
daysToArchive: 45,
},
log: {
level: 'error',
logger: ['console', 'file'],
},
createOptions: {
browserArgs: [
'--disable-web-security',
'--no-sandbox',
'--disable-web-security',
'--aggressive-cache-discard',
'--disable-cache',
'--disable-application-cache',
'--disable-offline-load-stale-cache',
'--disk-cache-size=0',
'--disable-background-networking',
'--disable-default-apps',
'--disable-extensions',
'--disable-sync',
'--disable-translate',
'--hide-scrollbars',
'--metrics-recording-only',
'--mute-audio',
'--no-first-run',
'--safebrowsing-disable-auto-update',
'--ignore-certificate-errors',
'--ignore-ssl-errors',
'--ignore-certificate-errors-spki-list',
],
},
mapper: {
enable: false,
prefix: 'tagone-',
},
db: {
mongodbDatabase: 'tokens',
mongodbCollection: '',
mongodbUser: '',
mongodbPassword: '',
mongodbHost: '',
mongoIsRemote: true,
mongoURLRemote: '',
mongodbPort: 27017,
redisHost: 'localhost',
redisPort: 6379,
redisPassword: '',
redisDb: 0,
redisPrefix: 'docker',
},
};
4 changes: 2 additions & 2 deletions src/config/upload.js → src/config/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import multer from 'multer';
import path from 'path';

const storage = multer.diskStorage({
destination: function (req, file, cb) {
const __dirname = path.resolve(path.dirname(''));
cb(null, path.resolve(__dirname, 'uploads'));
},
filename: function (req, file, cb) {
let filename = `wppConnect-${Date.now()}-${file.originalname}`;
const filename = `wppConnect-${Date.now()}-${file.originalname}`;
cb(null, filename);
},
});
Expand Down
Loading

0 comments on commit 7fa873d

Please sign in to comment.