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

Commit

Permalink
✨ Add launch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Feb 27, 2020
1 parent 303407c commit 59b3669
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 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.14",
"version": "1.3.15",
"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.14"
"staart-version": "1.3.15"
}
29 changes: 2 additions & 27 deletions src/helpers/mail.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { FRONTEND_URL, TEST_EMAIL } from "../config";
import { FRONTEND_URL } from "../config";
import { readFile } from "fs-extra";
import { join } from "path";
import i18n from "../i18n";
import { logError } from "@staart/errors";
import { sendMail, setupTransporter } from "@staart/mail";
import { sendMail } from "@staart/mail";
import { render } from "@staart/mustache-markdown";
import systemInfo from "systeminformation";
import pkg from "../../package.json";

/**
* Send a new email using AWS SES or SMTP
Expand All @@ -33,25 +30,3 @@ export const mail = async (
altText
});
};

setupTransporter();
sendMail({
to: TEST_EMAIL,
subject: "Test from Staart",
message: `This is an example email to test your Staart email configuration.\n\n${JSON.stringify(
{
time: systemInfo.time(),
package: {
name: pkg.name,
version: pkg.version,
repository: pkg.repository,
author: pkg.author,
"staart-version": pkg["staart-version"]
}
}
)}`
})
.then(() => {})
.catch(() =>
logError("Invalid email config", "Could not send a test email", 1)
);
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Staart } from "./app";
import { PORT, SENTRY_DSN } from "./config";
import { init } from "@sentry/node";
import "./init-tests";

if (SENTRY_DSN) init({ dsn: SENTRY_DSN });

Expand Down
36 changes: 36 additions & 0 deletions src/init-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { TEST_EMAIL } from "./config";
import { logError, success } from "@staart/errors";
import { sendMail, setupTransporter } from "@staart/mail";
import systemInfo from "systeminformation";
import pkg from "../package.json";
import redis from "@staart/redis";

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

setupTransporter();

if (process.env.NODE_ENV === "production")
sendMail({
to: TEST_EMAIL,
subject: "Test from Staart",
message: `This is an example email to test your Staart email configuration.\n\n${JSON.stringify(
{
time: systemInfo.time(),
package: {
name: pkg.name,
version: pkg.version,
repository: pkg.repository,
author: pkg.author,
"staart-version": pkg["staart-version"]
}
}
)}`
})
.then(() => {})
.catch(() =>
logError("Invalid email config", "Could not send a test email", 1)
);

0 comments on commit 59b3669

Please sign in to comment.