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
const express = require('express'); | |
const bodyparser = require('body-parser'); | |
const app = express(); | |
async function init() { | |
app.use(bodyparser.json({ limit: '50mb' })); | |
app.use(bodyparser.urlencoded({ limit: '50mb', extended: true, parameterLimit: 50000 })); | |
const approuting = require('./modules'); | |
const appmodules = new approuting(app); | |
appmodules.init(); | |
} |
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
const product = require('./product'); | |
const express = require('express'); | |
const router = express.Router(); | |
class ProductController { | |
constructor(app) { | |
router.get('/', product.getAllProducts); | |
router.post('/', product.addProduct); | |
router.put('/', product.updateProduct); | |
router.delete('/:id', product.deleteProduct); | |
app.use('/api/v1/products', 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
const productMssql = require('./product.mssql'); | |
class product { | |
async getAllProducts(req, res) { | |
try { | |
const output = await productMssql.getAllProducts(); | |
res.send(output); | |
} | |
catch (error) { | |
console.log(error); | |
} |
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
const mssqlcon = require('../../dbconnection'); | |
class ProductMSSql { | |
async getAllProducts() { | |
const conn = await mssqlcon.getConnection(); | |
const res = await conn.request().execute("getAllProducts"); | |
return res.recordset; | |
} | |
async addProduct(prod) { | |
const conn = await mssqlcon.getConnection(); | |
const res = await conn.request() |
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
const mssqlcon = require('../../dbconnection'); | |
class ProductMSSql { | |
async getAllProducts() { | |
const conn = await mssqlcon.getConnection(); | |
const res = await conn.request().execute("getAllProducts"); return res.recordset; | |
} | |
} | |
module.exports = new ProductMSSql(); |
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
const app = require('./app'); | |
const server = require('http').Server(app); | |
server.listen(4001,'localhost', ()=> { | |
console.log('Server Started'); | |
}); |
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
const express = require('express'); | |
const app = express(); | |
async function init() { | |
const approuting = require('./modules'); | |
const appmodules = new approuting(app); | |
appmodules.init(); | |
} | |
init(); | |
module.exports = app; |
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
class Module { | |
constructor(app) { | |
this.app = app; | |
} | |
init() { | |
const productcontroller = require('./product/product.controller'); | |
new productcontroller(this.app); | |
} | |
} | |
module.exports = Module; |
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
const product = require('./product'); | |
const express = require('express'); | |
const router = express.Router(); | |
class ProductController { | |
constructor(app) { | |
router.get('/', product.getAllProducts); | |
app.use('/api/v1/products', router); | |
} | |
} | |
module.exports = ProductController; |
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
const productMssql = require('./product.mssql'); | |
class product { | |
async getAllProducts(req, res) { | |
try { | |
const output = await productMssql.getAllProducts(); | |
res.send(output); | |
} | |
catch (error) { | |
console.log(error); | |
} |