Added lint and format scripts

This commit is contained in:
Peter Morton 2023-06-27 15:22:50 -05:00
parent 4650a4d5a3
commit 7df9f1e481
9 changed files with 3788 additions and 3041 deletions

21
.eslintrc.js Normal file
View File

@ -0,0 +1,21 @@
module.exports = {
env: {
node: true,
},
extends: ["eslint:recommended", "prettier"],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
],
parserOptions: {
ecmaVersion: "latest",
},
rules: {},
};

1869
.gitignore vendored

File diff suppressed because it is too large Load Diff

1
.prettierrc.json Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -1,10 +1,9 @@
# eo-services
created from template docker-image-template
created from template docker-image-template
## Key Files
* Jenkinsfile: Automation of build and deploy of docker image.
* Dockerfile: Docker Image specification.
* docker-bake.hcl: Docker build defintion file.
- Jenkinsfile: Automation of build and deploy of docker image.
- Dockerfile: Docker Image specification.
- docker-bake.hcl: Docker build defintion file.

View File

@ -2,8 +2,6 @@ const express = require("express");
const cors = require("cors");
const morgan = require("morgan");
const session = require("express-session");
const axios = require("axios");
const qs = require("query-string");
// dotenv
require("dotenv").config();
@ -35,13 +33,13 @@ app.listen(port, () => {
console.log(`Listening on port ${port}`);
});
//...
// ...
// Main Page
app.get("/", (req, res) => {
res.send({
message: "Engagement Orchestration Services",
});
});
//...
// ...
app.use("/unified-data-gateway", require("./routes/unified-data-gateway"));

1159
node_modules/.package-lock.json generated vendored

File diff suppressed because it is too large Load Diff

3735
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,8 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint --ext .js,.cjs --ignore-path .gitignore --fix .",
"format": "prettier . --write",
"start": "node index.js",
"dev": "nodemon index.js",
"build": "docker buildx bake",
@ -22,5 +24,14 @@
"morgan": "^1.10.0",
"nodemon": "^2.0.20",
"query-string": "^7.1.1"
},
"devDependencies": {
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.1.1",
"prettier": "2.8.8"
}
}

View File

@ -41,7 +41,7 @@ router.get("/", (req, res) => {
function query(referenceId) {
console.log("Executing Query");
var query = `query ($startTime: DateTime, $endTime: DateTime) {
const query = `query ($startTime: DateTime, $endTime: DateTime) {
findContactsCompletedBetween(startTime: $startTime, endTime: $endTime, filter: {interactionTypes : EMAIL}) {
totalCount
@ -115,10 +115,10 @@ router.get("/", (req, res) => {
}
}
}`;
var startTime = new Date(
const startTime = new Date(
new Date().setFullYear(new Date().getFullYear() - 2)
);
var endTime = new Date(new Date().setHours(new Date().getHours() - 1));
const endTime = new Date(new Date().setHours(new Date().getHours() - 1));
axios
.post(
@ -135,11 +135,11 @@ router.get("/", (req, res) => {
}
)
.then((result) => {
var contacts = result.data.data.findContactsCompletedBetween.edges;
const contacts = result.data.data.findContactsCompletedBetween.edges;
// Log error to console
if (result.data.errors && result.data.errors.length > 0) {
result.data.errors.forEach(function (error, i) {
result.data.errors.forEach(function (error) {
console.log("ERROR: Errors in results - " + error.message);
});
@ -147,8 +147,8 @@ router.get("/", (req, res) => {
result.data.errors = [];
}
var filteredContacts = [];
contacts.forEach(function (contact, i) {
const filteredContacts = [];
contacts.forEach(function (contact) {
if (contact.node.interaction.__typename === "Email") {
// threadId if Reference in Subject line will do
if (
@ -167,7 +167,7 @@ router.get("/", (req, res) => {
filteredContacts.length;
// Summary Values
var summary = {};
const summary = {};
summary.totalCount = filteredContacts.length;
summary.totalInboundCount = 0;
@ -178,7 +178,7 @@ router.get("/", (req, res) => {
filteredContacts[0].node.interaction.receivedDate
);
filteredContacts.forEach(function (contact, i) {
filteredContacts.forEach(function (contact) {
if (contact.node.direction === "INBOUND") {
summary.totalInboundCount++;
if (!summary.firstInboundContactStartDate) {