-
Notifications
You must be signed in to change notification settings - Fork 1
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
ac6dd15
commit 84a241a
Showing
32 changed files
with
2,560 additions
and
0 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,25 @@ | ||
name: Deploy Nodejs to Azure App Service | ||
|
||
on: | ||
push: | ||
branches: | ||
- final-submission | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source | ||
uses: actions/checkout@v3 | ||
- name: Setup Node.js version | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Deploy to Azure App Service | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: smartbarodanode | ||
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | ||
package: server |
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,123 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.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 | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# 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 variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# 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 | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# 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 |
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 @@ | ||
# SmartBOB |
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 @@ | ||
{ | ||
"expo": {} | ||
} |
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,61 @@ | ||
const jwt = require('jsonwebtoken'); | ||
const { validationResult } = require('express-validator'); | ||
const User = require('../models/User'); | ||
|
||
exports.register = async (req, res) => { | ||
const errors = validationResult(req); | ||
if (!errors.isEmpty()) { | ||
return res.status(400).json({ errors: errors.array() }); | ||
} | ||
|
||
try { | ||
const { accNo, username, panCard, cibilScore, type, GSTIN, password, balance } = req.body; | ||
|
||
let user = await User.findOne({ accNo }); | ||
if (user) { | ||
return res.status(400).json({ msg: 'User already exists' }); | ||
} | ||
|
||
user = new User({ accNo, username, panCard, cibilScore, type, GSTIN, password, balance }); | ||
await user.save(); | ||
|
||
const payload = { user: { id: user.id, accNo: user.accNo } }; | ||
jwt.sign(payload, 'secret', { expiresIn: '10d' }, (err, token) => { | ||
if (err) throw err; | ||
res.json({ token }); | ||
}); | ||
} catch (err) { | ||
console.error(err.message); | ||
res.status(500).send('Server error'); | ||
} | ||
}; | ||
|
||
exports.login = async (req, res) => { | ||
const errors = validationResult(req); | ||
if (!errors.isEmpty()) { | ||
return res.status(400).json({ errors: errors.array() }); | ||
} | ||
|
||
const { accNo, password } = req.body; | ||
|
||
try { | ||
let user = await User.findOne({ accNo }); | ||
if (!user) { | ||
return res.status(400).json({ msg: 'Invalid Credentials' }); | ||
} | ||
|
||
const isMatch = await user.comparePassword(password); | ||
if (!isMatch) { | ||
return res.status(400).json({ msg: 'Invalid Credentials' }); | ||
} | ||
|
||
const payload = { user: { id: user.id, accNo: user.accNo } }; | ||
jwt.sign(payload, 'secret', { expiresIn: '1h' }, (err, token) => { | ||
if (err) throw err; | ||
res.json({ token }); | ||
}); | ||
} catch (err) { | ||
console.error(err.message); | ||
res.status(500).send('Server 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const GST = require('../models/GST'); | ||
|
||
// Create a new GST | ||
exports.createGST = async (req, res) => { | ||
try { | ||
const gst = new GST(req.body); | ||
await gst.save(); | ||
res.status(201).send(gst); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
// Get all GST records | ||
exports.getAllGST = async (req, res) => { | ||
try { | ||
const gstRecords = await GST.find(); | ||
res.status(200).send(gstRecords); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
// Get GST by ID | ||
exports.getGSTById = async (req, res) => { | ||
try { | ||
const gst = await GST.findById(req.params.id); | ||
if (!gst) return res.status(404).send(); | ||
res.status(200).send(gst); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; |
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,67 @@ | ||
const LoanDetail = require('../models/LoanDetail'); | ||
const LoanIssued = require('../models/LoanIssued'); | ||
const User = require('../models/User'); | ||
|
||
// Create a new loan detail | ||
exports.createLoanDetail = async (req, res) => { | ||
try { | ||
const loanDetail = new LoanDetail(req.body); | ||
await loanDetail.save(); | ||
res.status(201).send(loanDetail); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
// Get all loan details | ||
exports.getAllLoanDetails = async (req, res) => { | ||
try { | ||
const loanDetails = await LoanDetail.find(); | ||
res.status(200).send(loanDetails); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
// Get loan detail by ID | ||
exports.getLoanDetailById = async (req, res) => { | ||
try { | ||
const loanDetail = await LoanDetail.findById(req.params.id); | ||
if (!loanDetail) return res.status(404).send(); | ||
res.status(200).send(loanDetail); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
exports.issueLoan = async (req, res) => { | ||
try { | ||
const { desc, recieverAccNo, type, amount, loanId, interest, status } = req.body; | ||
|
||
const receiver = await User.findOne({ accNo: recieverAccNo }); | ||
if (!receiver) { | ||
return res.status(404).json({ msg: 'Receiver not found' }); | ||
} | ||
|
||
const loanDetails = await LoanDetail.findById(loanId); | ||
if (!loanDetails) { | ||
return res.status(404).json({ msg: 'Loan details not found' }); | ||
} | ||
|
||
const loanIssued = new LoanIssued({ | ||
desc, | ||
recieverAccNo, | ||
type, | ||
amount, | ||
loanId, | ||
interest, | ||
status | ||
}); | ||
|
||
await loanIssued.save(); | ||
|
||
res.status(201).json(loanIssued); | ||
} catch (err) { | ||
res.status(500).json({ error: 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,37 @@ | ||
const LoanIssued = require('../models/LoanIssued'); | ||
const LoanDetails = require('../models/LoanDetail'); | ||
const User = require('../models/User'); | ||
|
||
// Create a new loan issued | ||
exports.createLoanIssued = async (req, res) => { | ||
try { | ||
const loanIssued = new LoanIssued(req.body); | ||
await loanIssued.save(); | ||
res.status(201).send(loanIssued); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
// Get all loans issued | ||
exports.getAllLoansIssued = async (req, res) => { | ||
try { | ||
const loansIssued = await LoanIssued.find(); | ||
res.status(200).send(loansIssued); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
// Get loan issued by ID | ||
exports.getLoanIssuedById = async (req, res) => { | ||
try { | ||
const loanIssued = await LoanIssued.findById(req.params.id); | ||
if (!loanIssued) return res.status(404).send(); | ||
res.status(200).send(loanIssued); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
|
Oops, something went wrong.