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

Commit

Permalink
✨ Add database check in init-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Feb 27, 2020
1 parent 59b3669 commit 2883f1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@staart/manager",
"version": "1.3.15",
"version": "1.3.16",
"main": "index.js",
"repository": "[email protected]:staart/api.git",
"author": "Anand Chowdhary <[email protected]>",
Expand Down Expand Up @@ -125,5 +125,5 @@
"setup"
],
"snyk": true,
"staart-version": "1.3.15"
"staart-version": "1.3.16"
}
2 changes: 1 addition & 1 deletion src/helpers/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const pool = createPool({
export const query = (
queryString: string,
values?: (string | number | boolean | Date | undefined)[]
): InsertResult | any =>
): Promise<InsertResult | any> =>
new Promise((resolve, reject) => {
pool.getConnection((error, connection) => {
if (error) return reject(error);
Expand Down
8 changes: 6 additions & 2 deletions src/init-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import { sendMail, setupTransporter } from "@staart/mail";
import systemInfo from "systeminformation";
import pkg from "../package.json";
import redis from "@staart/redis";
import { query } from "./helpers/mysql";

redis
.set(pkg.name, systemInfo.time().current)
.then(() => redis.del(pkg.name))
.then(() => success("Redis is listening"))
.then(() => success("Redis is up and listening"))
.catch(() => logError("Redis", "Unable to connect"));

setupTransporter();
query("SHOW tables")
.then(() => success("Database connection is working"))
.catch(() => logError("Database", "Unable to run query `SHOW tables`"));

setupTransporter();
if (process.env.NODE_ENV === "production")
sendMail({
to: TEST_EMAIL,
Expand Down

0 comments on commit 2883f1d

Please sign in to comment.