Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
✨ Support for emoji in database
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Jul 31, 2019
1 parent 54f5108 commit 3aef1ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "staart-manager",
"version": "1.0.115",
"version": "1.0.116",
"main": "index.js",
"repository": "[email protected]:AnandChowdhary/staart.git",
"author": "Anand Chowdhary <[email protected]>",
Expand Down Expand Up @@ -67,6 +67,7 @@
"@types/mustache": "^0.8.32",
"@types/mysql": "^2.15.6",
"@types/node": "^12.6.8",
"@types/node-emoji": "^1.8.1",
"@types/qrcode": "^1.3.3",
"@types/request": "^2.48.2",
"@types/response-time": "^2.3.3",
Expand Down Expand Up @@ -135,5 +136,5 @@
"setup"
],
"snyk": true,
"staart-version": "1.0.115"
"staart-version": "1.0.116"
}
6 changes: 5 additions & 1 deletion src/helpers/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { KeyValue } from "../interfaces/general";
import { boolValues, jsonValues, dateValues, readOnlyValues } from "./utils";
import { getUserPrimaryEmailObject } from "../crud/email";
import { InsertResult } from "../interfaces/mysql";
import { emojify, unemojify } from "node-emoji";

export const pool = createPool({
host: DB_HOST,
Expand Down Expand Up @@ -85,6 +86,7 @@ export const uncleanValues = (
)
).toISOString();
}
item[key] = emojify(item[key]);
});
return item;
});
Expand All @@ -100,7 +102,9 @@ export const cleanValues = (
) => {
values = values.map(value => {
// Clean up strings
if (typeof value === "string") value = value.trim();
if (typeof value === "string") {
value = unemojify(value.trim());
}
// Convert true to 1, false to 0
if (typeof value === "boolean") value = value ? 1 : 0;
// Convert Date to mysql datetime
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,11 @@
dependencies:
"@types/node" "*"

"@types/node-emoji@^1.8.1":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@types/node-emoji/-/node-emoji-1.8.1.tgz#689cb74fdf6e84309bcafce93a135dfecd01de3f"
integrity sha512-0fRfA90FWm6KJfw6P9QGyo0HDTCmthZ7cWaBQndITlaWLTZ6njRyKwrwpzpg+n6kBXBIGKeUHEQuBx7bphGJkA==

"@types/node@*", "@types/node@^12.6.8":
version "12.6.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.8.tgz#e469b4bf9d1c9832aee4907ba8a051494357c12c"
Expand Down

0 comments on commit 3aef1ac

Please sign in to comment.