ayiin 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ // src/methods/response.ts
2
+ class ResponseApi {
3
+ successResponse = (caption, data, code) => {
4
+ code = code ? Number(String(code) + "7400") : 2007400;
5
+ return {
6
+ responseCode: code,
7
+ responseSuccess: true,
8
+ responseMessage: `[Success] - ${caption}`,
9
+ responseData: data
10
+ };
11
+ };
12
+ badRequestResponse = (caption, title) => {
13
+ return {
14
+ responseCode: 4007400,
15
+ responseSuccess: false,
16
+ responseMessage: `[${title ? title : "Bad Request"}] - ${caption}`
17
+ };
18
+ };
19
+ invalidFieldsResponse = (caption) => {
20
+ return {
21
+ responseCode: 4007401,
22
+ responseSuccess: false,
23
+ responseMessage: `[Invalid Fields] - ${caption}`
24
+ };
25
+ };
26
+ notFoundResponse = (caption) => {
27
+ return {
28
+ responseCode: 4047400,
29
+ responseSuccess: false,
30
+ responseMessage: `[Not Found] - ${caption}`
31
+ };
32
+ };
33
+ unauthorizedResponse = (caption) => {
34
+ return {
35
+ responseCode: 4017400,
36
+ responseSuccess: false,
37
+ responseMessage: `[Unauthorized] - ${caption}`
38
+ };
39
+ };
40
+ internalServerErrorResponse = (caption) => {
41
+ return {
42
+ responseCode: 5007400,
43
+ responseSuccess: false,
44
+ responseMessage: `[Internal Server Error] - ${caption}`
45
+ };
46
+ };
47
+ }
48
+ var response_default = ResponseApi;
49
+ export {
50
+ response_default as default
51
+ };
@@ -1,34 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ // src/methods/tools.ts
3
2
  class Tools {
4
- constructor() {
5
- /**
6
- * Format money
7
- * @returns {string}
8
- * @memberof Tools
9
- * @param {number} amount
10
- * */
11
- this.formatMoney = (amount) => {
12
- return new Intl.NumberFormat('id-ID', {
13
- style: 'currency',
14
- currency: 'IDR'
15
- }).format(amount);
16
- };
17
- /**
18
- * Generate a random string
19
- * @returns {string}
20
- * @memberof Tools
21
- * @param {number} length
22
- * */
23
- this.randomString = (length) => {
24
- const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
25
- let random = '';
26
- for (let i = 0; i < length; i++) {
27
- random += alphabet[Math.floor(Math.random() * alphabet.length)];
28
- }
29
- return random;
30
- };
3
+ formatMoney = (amount, locales = "id-ID", options = {
4
+ style: "currency",
5
+ currency: "IDR"
6
+ }) => {
7
+ return new Intl.NumberFormat(locales, options).format(amount);
8
+ };
9
+ randomString = (length, prefix) => {
10
+ const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
11
+ let random = "";
12
+ for (let i = 0;i < length; i++) {
13
+ random += alphabet[Math.floor(Math.random() * alphabet.length)];
31
14
  }
15
+ return prefix ? prefix + random : random;
16
+ };
32
17
  }
33
- ;
34
- exports.default = Tools;
18
+ var tools_default = Tools;
19
+ export {
20
+ tools_default as default
21
+ };
package/bun.lock ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "lockfileVersion": 2,
3
+ "configVersion": 1,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "ayiin",
7
+ "devDependencies": {
8
+ "@types/bun": "latest",
9
+ },
10
+ "peerDependencies": {
11
+ "typescript": "^7",
12
+ },
13
+ },
14
+ },
15
+ "packages": {
16
+ "@types/bun": ["@types/bun@1.4.0", "", { "dependencies": { "bun-types": "1.4.0" } }, "sha512-K+lZULY23vRgK/CfTjFIV+tyifaNdSMlPh9j+6mQ/cLfpOznLyAuzgV/JQysyECpkBQLVMSyvjlr2fBUSA9wFQ=="],
17
+
18
+ "@types/node": ["@types/node@26.3.0", "", { "dependencies": { "undici-types": "~8.3.0" } }, "sha512-L3fgrnchriRC2ExBflb8j4uZZURHZfQsmQeyVzhjcHW4kkwVyo8/0h1B2MVzMTrYUJYu6G7EWs14hW/L9putqw=="],
19
+
20
+ "@typescript/typescript-aix-ppc64": ["@typescript/typescript-aix-ppc64@7.0.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ=="],
21
+
22
+ "@typescript/typescript-darwin-arm64": ["@typescript/typescript-darwin-arm64@7.0.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA=="],
23
+
24
+ "@typescript/typescript-darwin-x64": ["@typescript/typescript-darwin-x64@7.0.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA=="],
25
+
26
+ "@typescript/typescript-freebsd-arm64": ["@typescript/typescript-freebsd-arm64@7.0.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ=="],
27
+
28
+ "@typescript/typescript-freebsd-x64": ["@typescript/typescript-freebsd-x64@7.0.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw=="],
29
+
30
+ "@typescript/typescript-linux-arm": ["@typescript/typescript-linux-arm@7.0.2", "", { "os": "linux", "cpu": "arm" }, "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ=="],
31
+
32
+ "@typescript/typescript-linux-arm64": ["@typescript/typescript-linux-arm64@7.0.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ=="],
33
+
34
+ "@typescript/typescript-linux-loong64": ["@typescript/typescript-linux-loong64@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ=="],
35
+
36
+ "@typescript/typescript-linux-mips64el": ["@typescript/typescript-linux-mips64el@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA=="],
37
+
38
+ "@typescript/typescript-linux-ppc64": ["@typescript/typescript-linux-ppc64@7.0.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA=="],
39
+
40
+ "@typescript/typescript-linux-riscv64": ["@typescript/typescript-linux-riscv64@7.0.2", "", { "os": "linux", "cpu": "none" }, "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ=="],
41
+
42
+ "@typescript/typescript-linux-s390x": ["@typescript/typescript-linux-s390x@7.0.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw=="],
43
+
44
+ "@typescript/typescript-linux-x64": ["@typescript/typescript-linux-x64@7.0.2", "", { "os": "linux", "cpu": "x64" }, "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A=="],
45
+
46
+ "@typescript/typescript-netbsd-arm64": ["@typescript/typescript-netbsd-arm64@7.0.2", "", { "os": "none", "cpu": "arm64" }, "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA=="],
47
+
48
+ "@typescript/typescript-netbsd-x64": ["@typescript/typescript-netbsd-x64@7.0.2", "", { "os": "none", "cpu": "x64" }, "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA=="],
49
+
50
+ "@typescript/typescript-openbsd-arm64": ["@typescript/typescript-openbsd-arm64@7.0.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ=="],
51
+
52
+ "@typescript/typescript-openbsd-x64": ["@typescript/typescript-openbsd-x64@7.0.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg=="],
53
+
54
+ "@typescript/typescript-sunos-x64": ["@typescript/typescript-sunos-x64@7.0.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g=="],
55
+
56
+ "@typescript/typescript-win32-arm64": ["@typescript/typescript-win32-arm64@7.0.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ=="],
57
+
58
+ "@typescript/typescript-win32-x64": ["@typescript/typescript-win32-x64@7.0.2", "", { "os": "win32", "cpu": "x64" }, "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g=="],
59
+
60
+ "bun-types": ["bun-types@1.4.0", "", { "dependencies": { "@types/node": "*" } }, "sha512-iIKw23BspnQQYd3prITOBxeUsxBHnwzX6YJfGMuNOZzeNcMmVqzIIVGRm1l69ogaPQmb4wB6BN8mA5bE9YuC5Q=="],
61
+
62
+ "typescript": ["typescript@7.0.2", "", { "optionalDependencies": { "@typescript/typescript-aix-ppc64": "7.0.2", "@typescript/typescript-darwin-arm64": "7.0.2", "@typescript/typescript-darwin-x64": "7.0.2", "@typescript/typescript-freebsd-arm64": "7.0.2", "@typescript/typescript-freebsd-x64": "7.0.2", "@typescript/typescript-linux-arm": "7.0.2", "@typescript/typescript-linux-arm64": "7.0.2", "@typescript/typescript-linux-loong64": "7.0.2", "@typescript/typescript-linux-mips64el": "7.0.2", "@typescript/typescript-linux-ppc64": "7.0.2", "@typescript/typescript-linux-riscv64": "7.0.2", "@typescript/typescript-linux-s390x": "7.0.2", "@typescript/typescript-linux-x64": "7.0.2", "@typescript/typescript-netbsd-arm64": "7.0.2", "@typescript/typescript-netbsd-x64": "7.0.2", "@typescript/typescript-openbsd-arm64": "7.0.2", "@typescript/typescript-openbsd-x64": "7.0.2", "@typescript/typescript-sunos-x64": "7.0.2", "@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="],
63
+
64
+ "undici-types": ["undici-types@8.3.0", "", {}, "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ=="],
65
+ }
66
+ }
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "ayiin",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Library Pribadi Yang Gak Ada Isinya",
5
5
  "main": "ayiin/index.js",
6
6
  "scripts": {
7
- "build": "yarn tsc"
7
+ "build": "bun run scripts/build.ts"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/AyiinXd/ayiin.git"
8
12
  },
9
- "repository": "https://github.com/AyiinXd/ayiin",
10
13
  "author": {
11
14
  "name": "AyiinXd",
12
15
  "url": "https://github.com/AyiinXd"
@@ -15,14 +18,10 @@
15
18
  "ayiin"
16
19
  ],
17
20
  "license": "GPL-3.0-only",
18
- "dependencies": {
19
- "@types/node": "^22.7.4",
20
- "@types/nodemailer": "^6.4.17",
21
- "axios": "^1.7.7",
22
- "nodemailer": "^6.9.16"
23
- },
24
21
  "devDependencies": {
25
- "ts-node": "^10.9.2",
26
- "typescript": "^5.6.2"
22
+ "@types/bun": "latest"
23
+ },
24
+ "peerDependencies": {
25
+ "typescript": "^7"
27
26
  }
28
- }
27
+ }
package/save ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+
3
+ date=$(date +"%d-%m-%Y %H:%M:%S")
4
+
5
+ # Tanya dulu
6
+ read -p "Apakah ingin bump versi package.json? (y/N): " answer
7
+
8
+ if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
9
+ echo "📦 Bump patch version package.json"
10
+ npm version patch --no-git-tag-version
11
+ else
12
+ echo "ℹ️ Skip bump version"
13
+ fi
14
+
15
+ echo date: $date
16
+
17
+ echo "Adding all files to git"
18
+ git add .
19
+
20
+ echo "Committing to git"
21
+ git commit -m "Ayiin commit on $date"
22
+
23
+ echo "Pushing to git"
24
+ git push
25
+
26
+ echo "Done"
package/tsconfig.json CHANGED
@@ -1,19 +1,40 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "incremental": true,
4
- "target": "es2016",
5
- "module": "commonjs",
6
- "rootDir": "src",
3
+ "rootDir": "./src",
4
+ "outDir": "./ayiin",
7
5
  "resolveJsonModule": true,
8
6
  "declaration": true,
9
- "outDir": "./ayiin",
10
7
  "esModuleInterop": true,
11
8
  "forceConsistentCasingInFileNames": true,
12
- "strict": true,
13
9
  "alwaysStrict": true,
14
- "skipLibCheck": true
10
+ "incremental": true,
11
+ // Environment setup & latest features
12
+ "lib": ["ESNext"],
13
+ "target": "ESNext",
14
+ "module": "Preserve",
15
+ "moduleDetection": "force",
16
+ "jsx": "react-jsx",
17
+ "allowJs": true,
18
+ "types": ["bun"],
19
+
20
+ // Bundler mode
21
+ "moduleResolution": "bundler",
22
+ "allowImportingTsExtensions": true,
23
+ "noEmit": true,
24
+
25
+ // Best practices
26
+ "strict": true,
27
+ "skipLibCheck": true,
28
+ "noFallthroughCasesInSwitch": true,
29
+ "noUncheckedIndexedAccess": true,
30
+ "noImplicitOverride": true,
31
+
32
+ // Some stricter flags (disabled by default)
33
+ "noUnusedLocals": false,
34
+ "noUnusedParameters": false,
35
+ "noPropertyAccessFromIndexSignature": false,
36
+ "emitDeclarationOnly": true
15
37
  },
16
- "include": [
17
- "src/**/*"
18
- ]
19
- }
38
+ "include": ["src/**/*"],
39
+ "exclude": ["node_modules", "**/*.spec.ts"]
40
+ }
package/ayiin/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import Methods from "./methods";
2
- import { Options } from "./types/options";
3
- declare class Ayiin extends Methods {
4
- version: string;
5
- constructor(options?: Options);
6
- }
7
- export default Ayiin;
@@ -1,38 +0,0 @@
1
- import crypto from 'crypto';
2
- declare class Crypt {
3
- /**
4
- * Performs Base encryption and decryption.
5
- * @param {string | Buffer} input - The input data to be encrypted or decrypted.
6
- * @param {string} key - The encryption/decryption key.
7
- * @returns {Buffer} - The encrypted or decrypted data as a Buffer.
8
- */
9
- private baseCrypt;
10
- /**
11
- * Encrypts a plaintext message using the given key.
12
- * @param {string} text - The plaintext message to be encrypted.
13
- * @param {string} key - The encryption key.
14
- * @returns {string} - The encrypted data in Hex format.
15
- */
16
- encrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
17
- /**
18
- * Decrypts an encrypted message using the given key.
19
- * @param {string} encrypted - The encrypted data in Hex format.
20
- * @param {string} key - The decryption key.
21
- * @returns {string} - The decrypted plaintext message.
22
- */
23
- decrypt: (encrypted: string, key: string, bufferEncoding?: BufferEncoding) => string;
24
- /**
25
- * Converts a Hex string to its corresponding ASCII representation.
26
- * @param {string} hexString - The Hex string to be converted.
27
- * @returns {string} - The ASCII representation of the Hex string.
28
- */
29
- hexToAscii: (hexString: string) => string;
30
- /**
31
- * Converts an ASCII string to its corresponding Hex representation.
32
- * @param {string} asciiString - The ASCII string to be converted.
33
- * @returns {string} - The Hex representation of the ASCII string.
34
- */
35
- asciiToHex: (asciiString: string) => string;
36
- md5: (data: string, encoding: crypto.BinaryToTextEncoding) => string;
37
- }
38
- export default Crypt;
@@ -1,65 +0,0 @@
1
- import { BinaryToTextEncoding } from "crypto";
2
- import Mail from 'nodemailer/lib/mailer';
3
- import Crypt from "./crypt";
4
- import Tools from "./tools";
5
- import Mailer from "./mailer";
6
- import { Options } from "../types/options";
7
- declare class BaseMethods<C extends Crypt, M extends Mailer, T extends Tools> {
8
- crypt: C;
9
- mailer: M;
10
- tools: T;
11
- constructor(options?: Options);
12
- /**
13
- * Converts an ASCII string to its corresponding Hex representation.
14
- * @param {string} asciiString - The ASCII string to be converted.
15
- * @returns {string} - The Hex representation of the ASCII string.
16
- */
17
- asciiToHex: (asciiString: string) => string;
18
- /**
19
- * Converts a Hex string to its corresponding ASCII representation.
20
- * @param {string} hexString - The Hex string to be converted.
21
- * @returns {string} - The ASCII representation of the Hex string.
22
- */
23
- hexToAscii: (hexString: string) => string;
24
- /**
25
- * Encrypts a plaintext message using the given key.
26
- * @param {string} text - The plaintext message to be encrypted.
27
- * @param {string} key - The encryption key.
28
- * @returns {string} - The encrypted data in Hex format.
29
- */
30
- encrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
31
- /**
32
- * Decrypts an encrypted message using the given key.
33
- * @param {string} encrypted - The encrypted data in Hex format.
34
- * @param {string} key - The decryption key.
35
- * @returns {string} - The decrypted plaintext message.
36
- */
37
- decrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
38
- md5: (data: string, encoding: BinaryToTextEncoding) => string;
39
- /**
40
- * Send an email
41
- * @param {Mail.Options} options
42
- * */
43
- sendMail: (options: Mail.Options) => Promise<{
44
- success: boolean;
45
- message: string;
46
- }>;
47
- /**
48
- * Format money
49
- * @returns {string}
50
- * @memberof Tools
51
- * @param {number} amount
52
- * @param {"long" | "short"} [compactDisplay="long"]
53
- * */
54
- formatMoney: (value: number) => string;
55
- /**
56
- * Generate a random string
57
- * @returns {string}
58
- * @memberof Tools
59
- * @param {number} length
60
- * */
61
- randomString: (length: number) => string;
62
- }
63
- declare class Methods extends BaseMethods<Crypt, Mailer, Tools> {
64
- }
65
- export default Methods;
@@ -1,18 +0,0 @@
1
- import nodemailer from 'nodemailer';
2
- import Mail from 'nodemailer/lib/mailer';
3
- import SMTPTransport from 'nodemailer/lib/smtp-transport';
4
- import { Options } from '../types/options';
5
- type ResponseMailer = {
6
- success: boolean;
7
- message: string;
8
- };
9
- declare class Mailer {
10
- client?: nodemailer.Transporter<SMTPTransport.SentMessageInfo, SMTPTransport.Options>;
11
- constructor(opts?: Options);
12
- /**
13
- * Send an email
14
- * @param {Mail.Options} options
15
- * */
16
- sendMail: (options: Mail.Options) => Promise<ResponseMailer>;
17
- }
18
- export default Mailer;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const nodemailer_1 = __importDefault(require("nodemailer"));
16
- class Mailer {
17
- constructor(opts) {
18
- /**
19
- * Send an email
20
- * @param {Mail.Options} options
21
- * */
22
- this.sendMail = (options) => __awaiter(this, void 0, void 0, function* () {
23
- return yield new Promise((resolve, reject) => {
24
- if (!this.client) {
25
- throw new Error('Mailer is not initialized, Set Your Email and Password first');
26
- }
27
- this.client.sendMail(options, (err) => {
28
- if (err) {
29
- return reject({
30
- success: false,
31
- message: err.message
32
- });
33
- }
34
- else {
35
- return resolve({
36
- success: true,
37
- message: "Email sent successfully"
38
- });
39
- }
40
- });
41
- });
42
- });
43
- if (opts !== undefined) {
44
- this.client = nodemailer_1.default.createTransport({
45
- service: 'Gmail', // Use your email service
46
- auth: {
47
- user: opts.email, // Your email address
48
- pass: opts.password, // Your password
49
- },
50
- });
51
- }
52
- else {
53
- this.client = undefined;
54
- }
55
- }
56
- }
57
- ;
58
- exports.default = Mailer;
@@ -1,17 +0,0 @@
1
- declare class Tools {
2
- /**
3
- * Format money
4
- * @returns {string}
5
- * @memberof Tools
6
- * @param {number} amount
7
- * */
8
- formatMoney: (amount: number) => string;
9
- /**
10
- * Generate a random string
11
- * @returns {string}
12
- * @memberof Tools
13
- * @param {number} length
14
- * */
15
- randomString: (length: number) => string;
16
- }
17
- export default Tools;
@@ -1,4 +0,0 @@
1
- export type Options = {
2
- email?: string;
3
- password?: string;
4
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export type SendMail = {
2
- to: string;
3
- subject: string;
4
- htmlText: string;
5
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });