Added lint and format scripts
This commit is contained in:
parent
4650a4d5a3
commit
7df9f1e481
21
.eslintrc.js
Normal file
21
.eslintrc.js
Normal 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
1869
.gitignore
vendored
File diff suppressed because it is too large
Load Diff
1
.prettierrc.json
Normal file
1
.prettierrc.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@ -1,10 +1,9 @@
|
|||||||
# eo-services
|
# eo-services
|
||||||
|
|
||||||
created from template docker-image-template
|
created from template docker-image-template
|
||||||
|
|
||||||
## Key Files
|
## Key Files
|
||||||
|
|
||||||
* Jenkinsfile: Automation of build and deploy of docker image.
|
- Jenkinsfile: Automation of build and deploy of docker image.
|
||||||
* Dockerfile: Docker Image specification.
|
- Dockerfile: Docker Image specification.
|
||||||
* docker-bake.hcl: Docker build defintion file.
|
- docker-bake.hcl: Docker build defintion file.
|
||||||
|
|
||||||
|
|||||||
6
index.js
6
index.js
@ -2,8 +2,6 @@ const express = require("express");
|
|||||||
const cors = require("cors");
|
const cors = require("cors");
|
||||||
const morgan = require("morgan");
|
const morgan = require("morgan");
|
||||||
const session = require("express-session");
|
const session = require("express-session");
|
||||||
const axios = require("axios");
|
|
||||||
const qs = require("query-string");
|
|
||||||
|
|
||||||
// dotenv
|
// dotenv
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
@ -35,13 +33,13 @@ app.listen(port, () => {
|
|||||||
console.log(`Listening on port ${port}`);
|
console.log(`Listening on port ${port}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
//...
|
// ...
|
||||||
// Main Page
|
// Main Page
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.send({
|
res.send({
|
||||||
message: "Engagement Orchestration Services",
|
message: "Engagement Orchestration Services",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//...
|
// ...
|
||||||
|
|
||||||
app.use("/unified-data-gateway", require("./routes/unified-data-gateway"));
|
app.use("/unified-data-gateway", require("./routes/unified-data-gateway"));
|
||||||
|
|||||||
1159
node_modules/.package-lock.json
generated
vendored
1159
node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
3735
package-lock.json
generated
3735
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@ -5,6 +5,8 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"lint": "eslint --ext .js,.cjs --ignore-path .gitignore --fix .",
|
||||||
|
"format": "prettier . --write",
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"dev": "nodemon index.js",
|
"dev": "nodemon index.js",
|
||||||
"build": "docker buildx bake",
|
"build": "docker buildx bake",
|
||||||
@ -22,5 +24,14 @@
|
|||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"nodemon": "^2.0.20",
|
"nodemon": "^2.0.20",
|
||||||
"query-string": "^7.1.1"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ router.get("/", (req, res) => {
|
|||||||
function query(referenceId) {
|
function query(referenceId) {
|
||||||
console.log("Executing Query");
|
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}) {
|
findContactsCompletedBetween(startTime: $startTime, endTime: $endTime, filter: {interactionTypes : EMAIL}) {
|
||||||
|
|
||||||
totalCount
|
totalCount
|
||||||
@ -115,10 +115,10 @@ router.get("/", (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
var startTime = new Date(
|
const startTime = new Date(
|
||||||
new Date().setFullYear(new Date().getFullYear() - 2)
|
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
|
axios
|
||||||
.post(
|
.post(
|
||||||
@ -135,11 +135,11 @@ router.get("/", (req, res) => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
var contacts = result.data.data.findContactsCompletedBetween.edges;
|
const contacts = result.data.data.findContactsCompletedBetween.edges;
|
||||||
|
|
||||||
// Log error to console
|
// Log error to console
|
||||||
if (result.data.errors && result.data.errors.length > 0) {
|
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);
|
console.log("ERROR: Errors in results - " + error.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -147,8 +147,8 @@ router.get("/", (req, res) => {
|
|||||||
result.data.errors = [];
|
result.data.errors = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var filteredContacts = [];
|
const filteredContacts = [];
|
||||||
contacts.forEach(function (contact, i) {
|
contacts.forEach(function (contact) {
|
||||||
if (contact.node.interaction.__typename === "Email") {
|
if (contact.node.interaction.__typename === "Email") {
|
||||||
// threadId if Reference in Subject line will do
|
// threadId if Reference in Subject line will do
|
||||||
if (
|
if (
|
||||||
@ -167,7 +167,7 @@ router.get("/", (req, res) => {
|
|||||||
filteredContacts.length;
|
filteredContacts.length;
|
||||||
|
|
||||||
// Summary Values
|
// Summary Values
|
||||||
var summary = {};
|
const summary = {};
|
||||||
|
|
||||||
summary.totalCount = filteredContacts.length;
|
summary.totalCount = filteredContacts.length;
|
||||||
summary.totalInboundCount = 0;
|
summary.totalInboundCount = 0;
|
||||||
@ -178,7 +178,7 @@ router.get("/", (req, res) => {
|
|||||||
filteredContacts[0].node.interaction.receivedDate
|
filteredContacts[0].node.interaction.receivedDate
|
||||||
);
|
);
|
||||||
|
|
||||||
filteredContacts.forEach(function (contact, i) {
|
filteredContacts.forEach(function (contact) {
|
||||||
if (contact.node.direction === "INBOUND") {
|
if (contact.node.direction === "INBOUND") {
|
||||||
summary.totalInboundCount++;
|
summary.totalInboundCount++;
|
||||||
if (!summary.firstInboundContactStartDate) {
|
if (!summary.firstInboundContactStartDate) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user