Browse Source

first push

master
Akhilesh Chandak 1 year ago
commit
bac88f6ea5
10 changed files with 4531 additions and 0 deletions
  1. +188
    -0
      .gitignore
  2. +60
    -0
      app.js
  3. +4030
    -0
      package-lock.json
  4. +25
    -0
      package.json
  5. +8
    -0
      public/stylesheets/style.css
  6. +7
    -0
      routes/script.js
  7. +43
    -0
      utils/consts.js
  8. +76
    -0
      utils/db_config.js
  9. +77
    -0
      utils/response.js
  10. +17
    -0
      utils/scheduler.js

+ 188
- 0
.gitignore View File

@ -0,0 +1,188 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,node
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos,node
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
.log
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### Node Patch ###
# Serverless Webpack directories
.webpack/
# Optional stylelint cache
.stylelintcache
# SvelteKit build / generate output
.svelte-kit
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# Support for Project snippet scope
!.vscode/*.code-snippets
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,node
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

+ 60
- 0
app.js View File

@ -0,0 +1,60 @@
var createError = require('http-errors');
var express = require('express');
var app = express();
var path = require('path');
//var cookieParser = require('cookie-parser');
var logger = require('morgan');
const connection = require('./utils/db_config');
const scriptRouter = require('./routes/script');
const scheduler = require('./utils/scheduler');
const rfs = require('rotating-file-stream');
const logDirectory = path.join(__dirname, 'log')
const port = process.env.PORT || 5000;
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
// create a write stream (in append mode)
const accessLogStream = rfs.createStream('apiResponse.log', {
interval: '1d', // rotate daily
path: logDirectory
})
// setup the logger
app.use(logger('tiny', { stream: accessLogStream }));
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
//app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
//app.use('/', indexRouter);
app.use('/script', scriptRouter);
/* SCHEDULER */
//scheduler.routineFetchInvestors();
// catch 404 and forward to error handler
app.use(function (req, res, next) {
next(createError(404));
});
// error handler
app.use(function (err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
app.listen(port, () => {
console.log(`App is running on port ${port}`)
});
module.exports = app;

+ 4030
- 0
package-lock.json
File diff suppressed because it is too large
View File


+ 25
- 0
package.json View File

@ -0,0 +1,25 @@
{
"name": "p2p_liquiloan_script",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://git.nivesh.com:443/akhilesh.chandak/P2P_Liquiloan_Script.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"cookie-parser": "^1.4.6",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"morgan": "^1.10.0",
"node-cron": "^3.0.3",
"rotating-file-stream": "^3.1.1",
"sequelize": "^6.35.1",
"tedious": "^16.6.1"
}
}

+ 8
- 0
public/stylesheets/style.css View File

@ -0,0 +1,8 @@
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
a {
color: #00B7FF;
}

+ 7
- 0
routes/script.js View File

@ -0,0 +1,7 @@
const express = require('express');
const router = express.Router();
/* GET users listing. */
module.exports = router;

+ 43
- 0
utils/consts.js View File

@ -0,0 +1,43 @@
const ERROR_500 = "500";
const SUCCESS = "200";
const ERROR_400 = "400";
const ERROR_404 = "404";
const ERROR_409 = "409";
const ERROR_410 = "410";
const ERROR_401 = "401";
const UNAUTHORIZED_ERROR = "You are not authorized to use the app";
const ERROR_MESSAGE = "Oops,something went wrong";
const BUCKET_NAME_NIVESH = "nivesh-call-logs/recording";
const S3_BUCKET_NIVESH_CALL_URL= "https://nivesh-call-logs.s3.ap-south-1.amazonaws.com/recording/";
const BUCKET_NAME_SOA_REPORTS = "client-soa-reports/ELSS";
const S3_BUCKET_SOA_REPORTS_URL= "https://client-soa-reports.s3.ap-south-1.amazonaws.com/ELSS/";
const AWS_ACCESS_KEY_ID_TEST = "AKIA2C5JCOWXUXB4T3MV";
const AWS_SECRET_KEY_TEST = "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";
const EXOTEL_AUTHTOKEN = "Basic NWE0NjY1ZDU0MGViNzk5NjQxMGQ1NWJhYzllZmI5MTVhOTgyYWU2MmRmYWFkZmM0OmU0YTgzNjEwNjI1NWM5ZDllY2QxMDNiOWQwZGFmYWQ3ZTA1YjNjNTU1NDJhZjU3NQ=="
s3://kwikfoods/2020/
module.exports = {
ERROR_500,
ERROR_400,
ERROR_404,
ERROR_401,
UNAUTHORIZED_ERROR,
SUCCESS,
ERROR_MESSAGE,
ERROR_410,
ERROR_409,
BUCKET_NAME_NIVESH,
S3_BUCKET_NIVESH_CALL_URL,
BUCKET_NAME_SOA_REPORTS,
S3_BUCKET_SOA_REPORTS_URL,
AWS_ACCESS_KEY_ID_TEST,
AWS_SECRET_KEY_TEST,
EXOTEL_AUTHTOKEN
};

+ 76
- 0
utils/db_config.js View File

@ -0,0 +1,76 @@
const Sequelize = require('sequelize');
const tedious = require('tedious');
require('dotenv').config();
const db = {};
var sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER_NAME, process.env.DB_PASSWORD, {
host: process.env.DB_HOST,
dialect: process.env.DB_TYPE,
dialectModule: tedious,
define: { underscored: false },
logging: false,
timezone: 'ist',
dialectOptions: {
options: {
encrypt: true,
requestTimeout: 60000 // timeout = 30 seconds
}
}
});
sequelize
.authenticate()
.then(() => {
console.log('connected to database successfully')
}).catch(err => {
console.error('Unable to connect to the database:', err);
});
// sequelize.sync({
// force: false
// });
db.Sequelize = Sequelize;
db.sequelize = sequelize;
//db.exotelCalls = require('../model/exotelcalls')(sequelize, Sequelize);
//db.cRMLeadRemarks = require('../model/crmLeadRemarks')(sequelize, Sequelize);
//db.appRating.associations(db);
module.exports = db;
/*
const sql = require('mssql')
const sqlConfig = {
user: 'BSeMF',
password: 'nivesh2017',
database: 'providentialadvisory',
server: 'ec2-13-235-204-185.ap-south-1.compute.amazonaws.com',
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
},
options: {
encrypt: true, // for azure
trustServerCertificate: true // change to true for local dev / self-signed certs
}
}
const connection = async () => {
try {
console.log('ajksfkgjsafkksafkkfskf')
let con = await sql.connect(sqlConfig)
console.log('connection',con);
} catch (err) {
console.log(err);
}
};
connection();
*/

+ 77
- 0
utils/response.js View File

@ -0,0 +1,77 @@
const express = require('express');
const Constants = require('./consts.js');
const sendErrorMessage = (res, errorCode) => {
res.json({
status: errorCode,
message: Constants.ERROR_MESSAGE
});
};
const sendErrorCustomMessage = (res, text, errorCode) => {
res.json({
status: errorCode,
message: text
});
};
const sendSuccessMessage = (res, message) => {
res.json({
status: Constants.SUCCESS,
message: message
}).status(200);
};
const sendsuccessData = (res, message, data) => {
res.json({
status: Constants.SUCCESS,
message: message,
data: data
});
};
const sendErrorCustomData = (res, message, data) => {
res.json({
status: Constants.ERROR_500,
message: message,
data: data
});
};
const sendNotFoundMessage = (res, message) => {
res.json({
status: Constants.ERROR_404,
message: message
});
};
const sendErrorCustomDataWithCode = (res, message, data, code) => {
res.json({
status: code,
message: message,
data: data
});
};
const sendErrorCustomWithCode = (res, message, code) => {
res.json({
status: code,
message: message
})
}
module.exports = {
sendErrorMessage,
sendsuccessData,
sendSuccessMessage,
sendErrorCustomMessage,
sendErrorCustomData,
sendNotFoundMessage,
sendErrorCustomDataWithCode,
sendErrorCustomWithCode
}

+ 17
- 0
utils/scheduler.js View File

@ -0,0 +1,17 @@
'use strict';
const cron = require('node-cron');
const routineFetchInvestors = () => {
cron.schedule(process.env.SCHEDULER_RULE_EXOTEL_CALL, () => {
console.log("running scheduler");
// recordingController.callExotelRecording();
})
};
module.exports = {
routineFetchInvestors,
};

Loading…
Cancel
Save

Powered by TurnKey Linux.