-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00fc831
commit 1aa7da5
Showing
25 changed files
with
3,346 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NODE_ENV=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
NAME=DEV | ||
PORT=3255 | ||
ROUTING_PREFIX=/ | ||
DATA_BASE_URL=mongodb://localhost:27017/seqtdb | ||
|
||
PROXY=195.87.150.104 | ||
PROXY_PORT=80 | ||
|
||
GAPIMP_client_id=4pxVa7OvDNOMmT3GGTfdwM1dIvKACqdC | ||
GAPIMP_client_secret=fGV6XuvrUVVDqsAe | ||
|
||
GAPIMP_URL=https://api.dev.se.com/token | ||
bfoURL=https://api.qa.se.com/rest/bfo/opportunity/2.0/opportunities?seopptyreferenceId= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
NAME=PROD | ||
PORT=3255 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
NAME=STAGING | ||
PORT=3255 | ||
ROUTING_PREFIX=/seqt/ | ||
DATA_BASE_URL=mongodb://localhost:27017/seqtdb | ||
|
||
PROXY=165.225.94.17 | ||
PROXY_PORT=80 | ||
|
||
GAPIMP_client_id=4pxVa7OvDNOMmT3GGTfdwM1dIvKACqdC | ||
GAPIMP_client_secret=fGV6XuvrUVVDqsAe | ||
|
||
GAPIMP_URL=https://api.dev.se.com/token | ||
bfoURL=https://api.qa.se.com/rest/bfo/opportunity/2.0/opportunities?seopptyreferenceId= |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "attach", | ||
"name": "Attach", | ||
"port": 9229, | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
] | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"program": "${workspaceRoot}\\src\\server.js", | ||
"runtimeExecutable": "${workspaceRoot}\\node_modules\\.bin\\babel-node" | ||
} | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
{ | ||
"name": "njca", | ||
"name": "seqt-be", | ||
"version": "1.0.0", | ||
"description": "Simple NodeJS Archeticture can be used in an entrprise applications ", | ||
"description": "Schneider electric quotation tool.", | ||
"main": "server.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"debug": "nodemon --exec babel-node src/server.js --inspect", | ||
"start": "nodemon --exec babel-node src/server.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/AlameerAshraf/NodeJS-A-Clean-Archticture-NJCA.git" | ||
}, | ||
"keywords": [ | ||
"NodeJS", | ||
"Clean" | ||
], | ||
"author": "Alameer Ashraf Hassan", | ||
"author": "Alameer Ashraf", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/AlameerAshraf/NodeJS-A-Clean-Archticture-NJCA/issues" | ||
"devDependencies": { | ||
"@babel/core": "^7.7.4", | ||
"@babel/node": "^7.7.4", | ||
"@babel/preset-env": "^7.7.4", | ||
"nodemon": "^2.0.1" | ||
}, | ||
"homepage": "https://github.com/AlameerAshraf/NodeJS-A-Clean-Archticture-NJCA#readme", | ||
"dependencies": { | ||
"@babel/core": "^7.8.4", | ||
"@babel/node": "^7.8.4", | ||
"@babel/preset-env": "^7.8.4" | ||
"body-parser": "^1.19.0", | ||
"cors": "^2.8.5", | ||
"dotenv": "^8.2.0", | ||
"express": "^4.17.1", | ||
"global-tunnel-ng": "^2.7.1", | ||
"method-override": "^3.0.0", | ||
"mongodb": "^3.3.4", | ||
"mongoose": "^5.7.13", | ||
"mongoose-autopopulate": "^0.10.0", | ||
"mongoose-unique-validator": "^2.0.3", | ||
"request": "^2.88.0", | ||
"winston": "^3.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Router } from 'express'; | ||
import * as post from './post/post.routes'; | ||
|
||
|
||
// Define router.. | ||
var router = Router(); | ||
|
||
|
||
// controllers | ||
router.use('/posts' , post.default); | ||
|
||
|
||
|
||
export default router; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
|
||
|
||
async function paramsPostId(req , res , next , postId){ | ||
console.log(postId) | ||
}; | ||
|
||
|
||
async function createPost(req , res , next) { | ||
let user = req.body; | ||
let newUser = await userApps.createUser.execute(user); | ||
if (newUser.error != false) { | ||
res.json({ | ||
code: newUser.code, | ||
message: newUser.message, | ||
error: newUser.error, | ||
data: false | ||
}); | ||
} else { | ||
res.json({ | ||
error: false, | ||
message: '', | ||
data: newUser, | ||
total: 1 | ||
}); | ||
} | ||
}; | ||
|
||
async function getPost(req, res, next){ | ||
|
||
}; | ||
|
||
|
||
const actions = { | ||
createPost, | ||
paramsPostId, | ||
getPost | ||
}; | ||
|
||
export default actions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Router } from 'express'; | ||
import actions from './post.controller'; | ||
|
||
|
||
// Define router.. | ||
var router = Router(); | ||
|
||
router.param('postId' , actions.paramsPostId); | ||
|
||
|
||
|
||
router.route('/new') | ||
.post(actions.createPost); | ||
|
||
router.route('/load/:postId') | ||
.get(actions.getPost) | ||
|
||
|
||
|
||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Router } from 'express'; | ||
import * as api from './controllers'; | ||
|
||
// Define routes.. | ||
var router = Router(); | ||
|
||
// API Main route.. | ||
router.use('/api' , api.default); | ||
|
||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import postActions from './post/post.app'; | ||
|
||
export default () => { | ||
return Object.freeze({ | ||
postActions: postActions | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class createPost { | ||
constructor(){ | ||
|
||
} | ||
|
||
execute(){ | ||
|
||
} | ||
}; | ||
|
||
export default createPost; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import postService from ''; | ||
import postModel from ''; | ||
|
||
import createPost from './create-post/create-post'; | ||
|
||
|
||
// Construct the post service! | ||
const service = new postService(); | ||
|
||
export default () => { | ||
return Object.freeze({ | ||
createPost: new createPost(service) | ||
}) | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
DATA_BASE_CONNECTION_ERROR : 1000, | ||
INVALID_ACCESS_TOKEN : 1001, | ||
ERROR_LOADING_DATA_FROM_DATABASE : 1002, | ||
ERROR_LOADING_DATA_FROM_EXTERNAL_SOURCE : 1003, | ||
ENABLE_TO_SAVE_RECORD_TO_DATA_BASE : 1004, | ||
ENABLE_TO_UPDATE_RECORD_IN_DATA_BASE: 1005 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"seReference" : "OPP-1994-1611", | ||
"ownerName" : "Alameer Ashraf", | ||
"opportunityName" : "Project X", | ||
"projectCategoryP0" : "Category A", | ||
"projectCategoryS0" : "Category B", | ||
"projectCategoryS1" : "C", | ||
"leadingBusiness" : "Egypt EECE", | ||
"account" : { | ||
"id" : 34, | ||
"name" : "Name of the account" | ||
}, | ||
"endUserAccount" : { | ||
"id" : 23, | ||
"name" : "Mohamed Gamal" | ||
}, | ||
"countryOfDestination" : "Egypt", | ||
"salesStage" : "Development" , | ||
"marketSegment" : "SEGMENT", | ||
"marketSubSegment" : "SUB-SEGMENT", | ||
"solutionCenter" : { | ||
"id" : 24, | ||
"name" : "Egypt Solution Center" | ||
}, | ||
"rfpReceivedOn" : "02-12-2020", | ||
"plannedQuoteSubmitDecisionDate" : "05-01-2020", | ||
"customerQuoteIssuedDate" : "08-02-2020", | ||
"closeDate" : "02-02-2020", | ||
"currencyCode" : "EGP", | ||
"amount" : "1000000" | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import bodyParser from 'body-parser'; | ||
import cors from 'cors'; | ||
|
||
// API routes | ||
import * as routes from '../api'; | ||
|
||
|
||
// const app = express(); // for itelisense only.. | ||
|
||
export default ({ app })=> { | ||
var env = process.env.NODE_ENV; | ||
/** | ||
* Enable cors on all actions | ||
*/ | ||
app.use(cors()); | ||
|
||
/** | ||
* Transform string to JSON. | ||
*/ | ||
app.use(bodyParser.json()); | ||
|
||
/** | ||
* SERVERS | ||
*/ | ||
app.use(process.env.ROUTING_PREFIX , routes.default); | ||
|
||
/** | ||
* Check API health. | ||
*/ | ||
app.get(`${process.env.ROUTING_PREFIX}status`, (req, res) => { | ||
res.status(200).send("SEQT IS UP AND RUNNING!"); | ||
}); | ||
|
||
|
||
/** | ||
* Catch 404 and forward to error handle. | ||
*/ | ||
app.use((req, res, next) => { | ||
const err = new Error('Not Found'); | ||
err['status'] = 404; | ||
next(err); | ||
}); | ||
|
||
/** | ||
* Global error catcher. | ||
*/ | ||
app.use((err, req, res, next) => { | ||
res.status(err.status || 500); | ||
res.json({ | ||
errors:{ | ||
message: err.message | ||
} | ||
}); | ||
}); | ||
|
||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import expressLoader from './express'; | ||
import logger from './logger'; | ||
import mongo from './mongo'; | ||
|
||
|
||
export default async ({ app })=> { | ||
/** | ||
* MongoDB loader, creates mongoClient and connect to the db and return db connection. | ||
*/ | ||
new mongo(); | ||
|
||
|
||
/** | ||
* Laods express essentials | ||
*/ | ||
await expressLoader({ app }); | ||
logger.log("info" , "Express Loader has initalized successfully! ✅"); | ||
|
||
}; |
Oops, something went wrong.