first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-12-18 02:39:56 -05:00
commit 653ef00ca6
14 changed files with 4451 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
WRENCHJOB_PORT=3040
WRENCHJOB_POSTGRE_URL='postgresql://wrenchboard:wrenchboard@10.20.30.60:5432/wrenchboard'
+6
View File
@@ -0,0 +1,6 @@
node_modules
*.log
config.json
.queues
*.txt
docs
+117
View File
@@ -0,0 +1,117 @@
# FROM node:erbium
# pull the base image
# FROM node:alpine
FROM alpine:3.15
# Build args
ARG NODE_ENV
ENV NODE_VERSION 14.19.0
ENV NODE_ENV=$NODE_ENV
# install nginx
RUN apk update
RUN apk add nginx
RUN addgroup -g 1000 node \
&& adduser -u 1000 -G node -s /bin/sh -D node \
&& apk add --no-cache \
libstdc++ \
&& apk add --no-cache --virtual .build-deps \
curl \
&& ARCH= && alpineArch="$(apk --print-arch)" \
&& case "${alpineArch##*-}" in \
x86_64) \
ARCH='x64' \
CHECKSUM="8d5e638d88b62de2f147dee812a5d74e4860a20468eb7ff32c41a02b58e2aebf" \
;; \
*) ;; \
esac \
&& if [ -n "${CHECKSUM}" ]; then \
set -eu; \
curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \
echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs; \
else \
echo "Building from source" \
# backup build
&& apk add --no-cache --virtual .build-deps-full \
binutils-gold \
g++ \
gcc \
gnupg \
libgcc \
linux-headers \
make \
python3 \
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
108F52B48DB57BB0CC439B2997B01419BD92F80A \
B9E2F5981AA6E0CD28160D9FF13993A75599653C \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) V= \
&& make install \
&& apk del .build-deps-full \
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \
fi \
&& rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \
&& apk del .build-deps \
# smoke tests
&& node --version \
&& npm --version
ENV YARN_VERSION 1.22.17
RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& mkdir -p /opt \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& apk del .build-deps-yarn \
# smoke test
&& yarn --version \
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
CMD [ "npm", "start" ]
+36
View File
@@ -0,0 +1,36 @@
'use strict';
const properties = require('../package.json')
const resourcecategory = require('../service/resourcecategory');
//const openaifunc = require('../service/openaifunc');
const logger = require('../app/logger');
var controllers = {
getFamilyResourceCat: function(req, res) { //famresourcecat
resourcecategory.getfamilybanners(req, res, function(err, result) {
res.status(200).json({'status': 'OK', 'internal_return': 0, 'result_list': result.result,'total_record': result.total_record })
});
},
getResourceCat: function(req, res) {
//homebanners
resourcecategory.homebanners(req, res, function(err, dist) {
if (err) {
res.send(err);
}
res.json(dist);
});
},
// askOpenAi: function(req, res) {
// //homebanners
// openaifunc.openaipromt(req, res, function(err, dist) {
// if (err) {
// res.send(err);
// }
// res.json(dist);
// });
// },
};
module.exports = controllers;
+12
View File
@@ -0,0 +1,12 @@
'use strict';
const controller = require('./controller');
module.exports = function(app) {
app.route('/famresourcecat')
.get(controller.getFamilyResourceCat);
app.route('/homebanners')
.get(controller.getResourceCat);
// app.route('/askopenai')
// .get(controller.askOpenAi);
};
+57
View File
@@ -0,0 +1,57 @@
/**
* @file
* Configures the database connection
*/
const { Pool, Client } = require('pg');
const url = require('url');
const logger = require('./logger');
//const connectionString = 'postgresql://wrenchboard:wrenchboard@10.10.10.23:5432/wrenchboard';
const connectionString = process.env.POSTGRE_URL.replace(/'/g, '');
const params = url.parse(connectionString);
const auth = params.auth.split(':');
const config = {
user: auth[0],
password: auth[1],
host: params.hostname,
port: params.port,
database: params.pathname.split('/')[1],
ssl: false
};
const postgres = new Pool(config);
postgres.on('connect', client => {
logger.info('Connected to Database');
});
postgres.on('acquire', client => {
logger.info('Client is checked out from the DB connection pool');
});
postgres.on('remove', client => {
logger.info('Client is closed & removed from the DB connection pool');
});
postgres.on('error', (err, client) => {
logger.error(err);
});
// Connect to PostgreSQL
postgres.connect((err, client, release) => {
logger.info(connectionString);
if (err) {
logger.error('Error acquiring client', err.stack);
return null;
}
client.query('SELECT NOW()', (err, result) => {
release();
if (err) {
logger.error('Error executing query', err.stack);
return nul;
}
logger.info(result.rows);
});
});
module.exports = postgres;
+10
View File
@@ -0,0 +1,10 @@
/**
* @file
* Set up the app
*/
var _ = require('underscore');
var db = require('./db');
module.exports = function () {
db();
};
+61
View File
@@ -0,0 +1,61 @@
/**
* @file
* Defines logger for the microservice
*/
var winston = require('winston');
var Papertrail = require('winston-papertrail').Papertrail;
var serviceIdentifier = require('../package.json').name;
var host = process.env.LOG_SERVICE_HOST;
var port = process.env.LOG_SERVICE_PORT;
/**
* Class to provide logging facilities for the microservice
* @constructor
*/
var Logger = function () {
// Try to route logs to third party service
if (host && port) {
// Define our transport
var transport = new Papertrail({
levels: {
debug: 0,
info: 1,
error: 3
},
colors: {
debug: 'blue',
info: 'green',
error: 'red'
},
host,
port,
json: true,
colorize: true,
logFormat: (level, message) => {
return `[${serviceIdentifier}] ${level} : ${message}`;
}
});
// Handle exceptions
transport.exceptionsLevel = 'error';
winston.handleExceptions(transport);
}
this.info = winston.info;
this.error = winston.error;
this.debug = winston.debug;
};
module.exports = new Logger();
/**
* @typedef {Object} Logger
* @property {function} info - Log in level `info`
* @property {function} error - Log in level `error`
* @property {function} debug - Log in level `debug`
*/
+18
View File
@@ -0,0 +1,18 @@
version: '3'
services:
wrenchboard-socket-micro:
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
# image: registry.chiefsoft.net/flutterwave-transfer-micro:latest
volumes:
- ./:/app
- '/app/node_modules'
ports:
- 3040:3040
environment:
- PORT=${WRENCHJOB_PORT}
- POSTGRE_URL=${WRENCHJOB_POSTGRE_URL}
volumes:
src:
+3489
View File
File diff suppressed because it is too large Load Diff
+38
View File
@@ -0,0 +1,38 @@
{
"name": "wrenhboard-socket-micro",
"version": "0.0.1",
"description": "A microservice to handle wrenchboard socket",
"main": "server.js",
"scripts": {
"generate-docs": "jsdoc ./api/*.js ./api/**/*.js ./app/*.js ./app/**/*.js ./service/*.js ./service/**/*.js -d docs",
"lint": "eslint ./ --ext .js",
"start": "node server.js",
"start:dev": "nodemon server.js",
"test": "npm run lint"
},
"author": "WrenchBoard Support <support@wrenchboard.com>",
"dependencies": {
"axios": "^1.6.7",
"body-parser": "^1.19.0",
"openai": "^4.28.4",
"openapi-types": "^10.0.0",
"pg": "8.7.1",
"pg-pool": "^3.5.1",
"request": "^2.88.2",
"swagger-autogen": "^2.17.2",
"swagger-jsdoc": "^6.1.0",
"swagger-ui-express": "^4.3.0",
"underscore": "^1.8.3",
"url": "^0.11.0",
"winston": "^2.3.1",
"winston-papertrail": "^1.0.4",
"cors": "^2.8.5",
"express": "^4.17.3",
"socket.io": "^4.4.1"
},
"devDependencies": {
"eslint": "^8.57.0",
"jsdoc": "^4.0.2",
"nodemon": "^3.1.0"
}
}
+97
View File
@@ -0,0 +1,97 @@
const express = require('express');
const logger = require('./app/logger');
const port = process.env.PORT || 3040;
const db = require('./app/db')
const app = express();
const http = require("http");
const { Server } = require("socket.io");
const cors = require("cors");
app.use(cors());
const server = http.createServer(app);
console.log("ENTER THE SOCKET");
//console.log(server);
//console.log(http);
const io = new Server(server, {
cors: {
origin: ['http://localhost:3000',
'http://localhost:3040',
'http://10.0.0.248:3000',
'https://10.0.0.248:3000',
'http://localhost:9082/',
'http://10.204.5.100:9082',
'http://localhost:9083/',
'https://dev-users.wrenchboard.com/',
'https://dev-users.wrenchboard.com:3000/',
'https://users.wrenchboard.com/',
'https://www.wrenchboard.com/',
'https://www.wrenchboard.ng/',
'https://dev-www.wrenchboard.com/',
'http://76.209.103.227:30040',
'http://socket-dev.wrenchboard.com',
'https://socket-dev.wrenchboard.com',
'https://socket.wrenchboard.com',
'*','*:*'],
methods: ["GET", "POST"],
},
});
//io.origins('*:*') // for latest version
io.on("connection", (socket) => {
console.log(`User Connected: ${socket.id}`);
socket.on("join_room", (data) => {
socket.join(data);
console.log(data);
});
socket.on("send_message", (data) => {
// console.log("send_message", data.room);
console.log("START ************************send_message");
console.log("send_message ", data.room);
console.log("send_message DATA ", data);
console.log("END ************************send_message");
socket.to(data.room).emit("receive_message", data);
});
// to be removed
socket.on("marketjob", (data) => {
console.log("marketjob", data.room);
socket.to(data.room).emit("marketjob_actions", data);
});
socket.on("marketjob_added", (data) => {
console.log("START ************************marketjob_added");
console.log("marketjob_added ", data.room);
console.log("marketjob_added DATA ", data);
console.log("END ************************marketjob_added");
Qstring = "SELECT * FROM members_jobs_contract ORDER BY id desc LIMIT 20";
//" SELECT id,uid,job_uid,originalname FROM from members_jobs_files WHERE job_uid= '"+ data.job_uid +"'";
db.query(Qstring, function (err, result) {
try {
if (err) throw err;
socket.to(data.room).emit("received_refreshmarket_jobs", result.rows);
} catch (e) {
socket.to(data.room).emit("received_refreshmarket_jobs", data);
}
});
});
socket.on("family", (data) => {
console.log("family", data.room);
socket.to(data.room).emit("family_actions", data);
});
});
server.listen(port, () => {
console.log("SERVER IS RUNNING");
});
//https://github.com/lemoncode21/nodejs-kafka/blob/master/index.js
+212
View File
@@ -0,0 +1,212 @@
'use strict';
const request = require('request');
const db = require('../app/db')
const logger = require('../app/logger');
const { Configuration, OpenAIApi } = require('openai');
// const config = new Configuration({
// apiKey: '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',
// });
// const openai = new OpenAIApi(config);
var openaifunc = {
openaipromt: function (req, res, next) {
// const openai2 = new OpenAIApi({
// api_key: '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'
// });
const config = new Configuration({
apiKey: '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',
});
const openai = new OpenAIApi();
let message ="What is robots ?";
// Calling the OpenAI API to complete the message
openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: chatArray.concat([{ role: "user", content: message }])
}).then((response) => {
// Save the user's message and the AI's response to the chatArray
chatArray.push({ role: "user", content: message });
chatArray.push({ role: "assistant", content: response.data.choices[0].message.content });
// Return the chatArray as a JSON response
// res.json(chatArray);
let resultItem ={
"result": chatArray,
"total_record": 4
}
next(null, resultItem ); // pass control to the next handler
});
},
homebanners: function (req, res, next) {
var result=[];
this.RecoCheckOffers(req, res, function(err, result){
logger.info("************************ aaaa");
logger.info(result);
logger.info("************************ bbbb");
});
var result_list =[
{
"title": "Some family accounts are yet to log in.",
"contract": null,
"card_type": "FAMILY_NOLOGIN",
"card_style": null,
"description": "Some family members have not logged in - a little nudge might help.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"banner_location": "URL",
"link_path": "acc-family",
"button_text": "Continue",
"short_button_text": "View Now",
"short_title": "Some family accounts are yet to log in",
"short_description": "Help your family member get started.",
"short_style": "short_style"
},
{
"title": "Yo man , you have Coupons to play with",
"contract": null,
"card_type": "COUPONS",
"card_style": null,
"description": "You have received some cash coupons waiting to be redeemed.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-coupons.jpg",
"banner_location": "LOCAL",
"link_path": "my-coupon",
"button_text": "Continue",
"short_button_text": "Redeem",
"short_title": "Redeem your Cash Coupons!",
"short_description": "You have received some cash coupons waiting to be redeemed.",
"short_style": "short_style lg"
},
{
"title": "Some of your task as owner Need Review now ",
"contract": null,
"card_type": "REVIEWJOB",
"card_style": null,
"description": "Some of your task as owner Need Review now,Some of your task as owner Need Review now, S Need Review now",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-job-due.jpg",
"banner_location": "LOCAL",
"link_path": "my-review-jobs",
"button_text": "View Tasks",
"short_button_text": "Start Review",
"short_title": "Review Ready Tasks",
"short_description": "Some of your jobs are waiting for approval ",
"short_style": "short_style lr"
},
{
"title": "Some of your task as owner of the tasks are due ",
"contract": null,
"card_type": "PASTDUEJOB",
"card_style": null,
"description": "Some of your task as owner of the tasks are due, Some of your task as owner of the tasks are due",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/past-due.jpg",
"banner_location": "URL",
"link_path": "my-pastdue-jobs",
"button_text": "View Tasks",
"short_button_text": "View",
"short_title": "Past Due Tasks",
"short_description": "Some of you task are now past due",
"short_style": "short_style lr"
},
{
"title": "Share WrenchBoard with a friend.",
"contract": null,
"card_type": "INVITE",
"card_style": null,
"description": "Show WrenchBoard to a friend and earn free coupons. Get started.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-refer.jpg",
"banner_location": "LOCAL",
"link_path": "referral",
"button_text": "Continue",
"short_button_text": "View now",
"short_title": "Invite a Friend - get Rewards",
"short_description": "Share WrenchBoard with a friend.",
"short_style": "short_style by"
}
];
let resultItem ={
"result": result_list,
"total_record": 5
}
next(null, resultItem ); // pass control to the next handler
},
RecoCheckOffers : function (req, res, next) {
let Qstring ="SELECT * FROM members_jobs_offer WHERE expire > now() "+
"AND status = 1 AND client_id > 0 AND client_id =" +req.body.member_id;
logger.info(Qstring);
db.query(Qstring, function (err, result) {
try {
if (err) throw err;
let resultItem ={
"result":
[
{
"title": "Share RecoCheckOffers with a friend.",
"contract": null,
"card_type": "INVITE",
"card_style": null,
"description": "Show WrenchBoard to a friend and earn free coupons. Get started.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-refer.jpg",
"banner_location": "LOCAL",
"link_path": "referral",
"button_text": "Continue",
"short_button_text": "View now",
"short_title": "Invite a Friend - get Rewards",
"short_description": "Share WrenchBoard with a friend.",
"short_style": "short_style by"
}
]
,
"total_record": result.rowCount
};
logger.info(result);
next(null, resultItem); // pass control to the next handler
} catch (e) {
next(e.message, null); // pass control to the next handler
}
});
}
};
module.exports = openaifunc;
+296
View File
@@ -0,0 +1,296 @@
'use strict';
const request = require('request');
const db = require('../app/db')
const logger = require('../app/logger');
var resourcecategory = {
getfamilybanners: function (req, res, next) {
//console.log("REQ---->",req.body.uid);
var data = {
"uid": req.body.uid,
"member_id": req.body.member_id,
"limit": (req.body.limit != null && req.body.limit !== "") ? req.body.limit : 20,
"sessionid": req.body.sessionid,
"page": req.body.page
};
let Qstring =""; // "SELECT uid,id,username FROM members LIMIT 10";
let QextraString ="";
if ( req.body.uid != null && req.body.uid !== ""){
QextraString= " AND j.country IN (SELECT c.country FROM members_wallet w " +
" LEFT JOIN currency c ON c.code =w.currency " +
" LEFT JOIN members m ON m.id = w.member_id " +
" WHERE m.uid = '"+req.body.uid+"' )";
}
Qstring = " SELECT j.title,j.description,m.id AS job_id,m.expire,m.job_description,j.price, " +
" m.offer_code,j.timeline_days, to_char(m.expire, 'Dy Mon dd, yyyy HH:MI AM') AS expire2," +
" m.uid AS offer_uid,j.uid AS job_uid,m.added::date AS offer_added,j.country AS job_country, " +
" c.code AS currency_code, c.description AS currency_description,j.country, j.category " +
" FROM members_jobs_offer m " +
" LEFT JOIN members_jobs j ON j.id=m.job_id " +
" LEFT JOIN currency c ON c.country=j.country " +
" WHERE m.status = 1 AND m.client_id=0 " +
" AND m.expire IS NOT NULL " +
" AND m.public_view = 1 AND m.expire> now() AND j.status = 1 " + QextraString +
" ORDER BY m.expire DESC LIMIT "+ data.limit;
// // logger.info(Qstring);
// db.query(Qstring, function (err, result) {
// try {
// if (err) throw err;
// let resultItem ={
// "result": result.rows,
// "total_record": result.rowCount
// }
// // logger.info(result);
// next(null, resultItem); // pass control to the next handler
// // next(null, result.rows); // pass control to the next handler
// } catch (e) {
// next(e.message, null); // pass control to the next handler
// }
// });
var bannerArray = {
"tab_categories": {
"data": [
{
"uid": "f1b99eee-607b-42f5-ad2f-d4f95065ccb9",
"name": "blog",
"content": "Blog",
"description" : "Short description for this item",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners//kid-res/blog.jpg",
"enabled": 1,
"action" : "fam-blog"
},
{
"uid": "8208c72d-c5e1-43b2-bbe3-de285845427c",
"name": "questions",
"content": "Questions?",
"description" : "Short description for this item",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/kid-res/questions.jpg",
"enabled": 1,
"action" : "ai-question"
},
{
"uid": "3428c6db-af5f-49bf-b879-4a533d6b98bf",
"name": "interesting",
"content": "Interesting",
"description" : "Short description for this item",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
{
"uid": "3b0ff711-dd42-4488-a7f4-a5fffd364701",
"name": "library",
"content": "Library",
"description" : "Short description for this item",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/kid-res/library.jpg",
"enabled": 1,
"action" : "myfiles"
},
{
"uid": "f50eb4ca-37b3-45f0-93e9-e2b33b8b93d7",
"name": "games",
"content": "Games",
"description" : "Short description for this item",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/kid-res/games.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
{
"uid": "5751a446-7d52-498a-a0a2-06c926cdd5c4",
"name": "ai-lab",
"content": "AI Lab",
"description" : "Short description for this item",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/kid-res/ai.jpg",
"enabled": 1,
"action" : "ai-lab"
},
]
}
};
// "another1task": {
// "banner": {
// "image": "https://www.wrenchboard.com/assets/images/apps/banners/recommend-banner.jpg",
// "icon": "bannerimage.icon",
// "style": "style4",
// "text": "Dummy for now",
// "description": "dummy dummy dummy",
// "action": "thisaction"
// }
// },
let resultItem ={
"result": bannerArray,
"total_record": 4
}
next(null, resultItem ); // pass control to the next handler
},
homebanners: function (req, res, next) {
var result=[];
this.RecoCheckOffers(req, res, function(err, result){
logger.info("************************ aaaa");
logger.info(result);
logger.info("************************ bbbb");
});
var result_list =[
{
"title": "Some family accounts are yet to log in.",
"contract": null,
"card_type": "FAMILY_NOLOGIN",
"card_style": null,
"description": "Some family members have not logged in - a little nudge might help.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"banner_location": "URL",
"link_path": "acc-family",
"button_text": "Continue",
"short_button_text": "View Now",
"short_title": "Some family accounts are yet to log in",
"short_description": "Help your family member get started.",
"short_style": "short_style"
},
{
"title": "Yo man , you have Coupons to play with",
"contract": null,
"card_type": "COUPONS",
"card_style": null,
"description": "You have received some cash coupons waiting to be redeemed.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-coupons.jpg",
"banner_location": "LOCAL",
"link_path": "my-coupon",
"button_text": "Continue",
"short_button_text": "Redeem",
"short_title": "Redeem your Cash Coupons!",
"short_description": "You have received some cash coupons waiting to be redeemed.",
"short_style": "short_style lg"
},
{
"title": "Some of your task as owner Need Review now ",
"contract": null,
"card_type": "REVIEWJOB",
"card_style": null,
"description": "Some of your task as owner Need Review now,Some of your task as owner Need Review now, S Need Review now",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-job-due.jpg",
"banner_location": "LOCAL",
"link_path": "my-review-jobs",
"button_text": "View Tasks",
"short_button_text": "Start Review",
"short_title": "Review Ready Tasks",
"short_description": "Some of your jobs are waiting for approval ",
"short_style": "short_style lr"
},
{
"title": "Some of your task as owner of the tasks are due ",
"contract": null,
"card_type": "PASTDUEJOB",
"card_style": null,
"description": "Some of your task as owner of the tasks are due, Some of your task as owner of the tasks are due",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/past-due.jpg",
"banner_location": "URL",
"link_path": "my-pastdue-jobs",
"button_text": "View Tasks",
"short_button_text": "View",
"short_title": "Past Due Tasks",
"short_description": "Some of you task are now past due",
"short_style": "short_style lr"
},
{
"title": "Share WrenchBoard with a friend.",
"contract": null,
"card_type": "INVITE",
"card_style": null,
"description": "Show WrenchBoard to a friend and earn free coupons. Get started.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-refer.jpg",
"banner_location": "LOCAL",
"link_path": "referral",
"button_text": "Continue",
"short_button_text": "View now",
"short_title": "Invite a Friend - get Rewards",
"short_description": "Share WrenchBoard with a friend.",
"short_style": "short_style by"
}
];
let resultItem ={
"result": result_list,
"total_record": 5
}
next(null, resultItem ); // pass control to the next handler
},
RecoCheckOffers : function (req, res, next) {
let Qstring ="SELECT * FROM members_jobs_offer WHERE expire > now() "+
"AND status = 1 AND client_id > 0 AND client_id =" +req.body.member_id;
logger.info(Qstring);
db.query(Qstring, function (err, result) {
try {
if (err) throw err;
let resultItem ={
"result":
[
{
"title": "Share RecoCheckOffers with a friend.",
"contract": null,
"card_type": "INVITE",
"card_style": null,
"description": "Show WrenchBoard to a friend and earn free coupons. Get started.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-refer.jpg",
"banner_location": "LOCAL",
"link_path": "referral",
"button_text": "Continue",
"short_button_text": "View now",
"short_title": "Invite a Friend - get Rewards",
"short_description": "Share WrenchBoard with a friend.",
"short_style": "short_style by"
}
]
,
"total_record": result.rowCount
};
logger.info(result);
next(null, resultItem); // pass control to the next handler
} catch (e) {
next(e.message, null); // pass control to the next handler
}
});
},
RecoCheckFamilyLogin : function (req, res, next) {},
RecoCheckFamilyCount : function (req, res, next) {},
RecoCheckCoupons : function (req, res, next) {},
RecoCheckTaskDue : function (req, res, next) {},
RecoCheckTaskReview : function (req, res, next) {},
RecoCheckBlog : function (req, res, next) {},
RecoOffersInterest : function (req, res, next) {},
RecoReferAFreind : function (req, res, next) {},
RecoPendingInterestCount : function (req, res, next) {}
};
module.exports = resourcecategory;