Skip to content

Adding temporary changes to Github #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b2c132c
Adding temporary changes to Github
madhubalaselvaraj May 13, 2025
fb298ab
updated app.js
madhubalaselvaraj May 14, 2025
f63bacf
carmodel and carmake django models updated
madhubalaselvaraj May 14, 2025
153b8b9
create Django proxy services of backend api
madhubalaselvaraj May 14, 2025
b765b7c
login logout code updated
madhubalaselvaraj May 15, 2025
12ca0fc
register code updated
madhubalaselvaraj May 15, 2025
a96820e
Create main.yml
madhubalaselvaraj May 15, 2025
1073ce0
Update main.yml
madhubalaselvaraj May 15, 2025
f931fbc
Update main.yml
madhubalaselvaraj May 15, 2025
ee58ebb
lint python file error cleared
madhubalaselvaraj May 15, 2025
4cbc0b5
lint update
madhubalaselvaraj May 15, 2025
f26ae3e
Update main.yml
madhubalaselvaraj May 15, 2025
a8368d3
clearing lint errors
madhubalaselvaraj May 15, 2025
a08701d
Merge branch 'main' of https://github.com/madhubalaselvaraj/xrwvm-ful…
madhubalaselvaraj May 15, 2025
a27616e
Create main.yml
madhubalaselvaraj May 15, 2025
80eb28c
view file updated
madhubalaselvaraj May 15, 2025
7644eee
view file updated
madhubalaselvaraj May 15, 2025
062c83a
updated javascript files
madhubalaselvaraj May 15, 2025
9ea4137
updated review file
madhubalaselvaraj May 15, 2025
2cbac7b
deployed the application
madhubalaselvaraj May 16, 2025
37c5008
latest commit
madhubalaselvaraj May 16, 2025
a2d3a15
url update
madhubalaselvaraj May 16, 2025
14671c8
updated
madhubalaselvaraj May 16, 2025
39efbd1
updated dealer.js file
madhubalaselvaraj May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/create_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 'Lint Code'

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
lint_python:
name: Lint Python Files
runs-on: ubuntu-latest

steps:

- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8

- name: Print working directory
run: pwd

- name: Run Linter
run: |
pwd
# This command finds all Python files recursively and runs flake8 on them
find . -name "*.py" -exec flake8 {} +
echo "Linted all the python files successfully"

lint_js:
name: Lint JavaScript Files
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install JSHint
run: npm install jshint --global

- name: Run Linter
run: |
# This command finds all JavaScript files recursively and runs JSHint on them
find ./server/database -name "*.js" -exec jshint {} +
echo "Linted all the js files successfully"
59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 'Lint Code'

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
lint_python:
name: Lint Python Files
runs-on: ubuntu-latest

steps:

- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8

- name: Print working directory
run: pwd

- name: Run Linter
run: |
pwd
# This command finds all Python files recursively and runs flake8 on them
find . -name "*.py" -exec flake8 {} +
echo "Linted all the python files successfully"

lint_js:
name: Lint JavaScript Files
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install JSHint
run: npm install jshint --global

- name: Run Linter
run: |
# This command finds all JavaScript files recursively and runs JSHint on them
find ./server/database -name "*.js" -exec jshint {} +
echo "Linted all the js files successfully"
25 changes: 25 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.0-slim-bookworm

ENV PYTHONBUFFERED 1
ENV PYTHONWRITEBYTECODE 1

ENV APP=/app

# Change the workdir.
WORKDIR $APP

# Install the requirements
COPY requirements.txt $APP

RUN pip3 install -r requirements.txt

# Copy the rest of the files
COPY . $APP

EXPOSE 8000

RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/bin/bash","/app/entrypoint.sh"]

CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangoproj.wsgi"]
124 changes: 71 additions & 53 deletions server/database/app.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
/* jshint node: true, esversion: 8 */
'use strict';

const express = require('express');
const mongoose = require('mongoose');
const fs = require('fs');
const cors = require('cors')
const app = express()
const port = 3030;
const cors = require('cors');
const bodyParser = require('body-parser');

app.use(cors())
app.use(require('body-parser').urlencoded({ extended: false }));
const app = express();
const port = 3030;

const reviews_data = JSON.parse(fs.readFileSync("reviews.json", 'utf8'));
const dealerships_data = JSON.parse(fs.readFileSync("dealerships.json", 'utf8'));
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));

mongoose.connect("mongodb://mongo_db:27017/",{'dbName':'dealershipsDB'});
const reviewsData = JSON.parse(fs.readFileSync('reviews.json', 'utf8'));
const dealershipsData = JSON.parse(fs.readFileSync('dealerships.json', 'utf8'));

mongoose.connect('mongodb://mongo_db:27017/', { dbName: 'dealershipsDB' });

const Reviews = require('./review');

const Dealerships = require('./dealership');

try {
Reviews.deleteMany({}).then(()=>{
Reviews.insertMany(reviews_data['reviews']);
});
Dealerships.deleteMany({}).then(()=>{
Dealerships.insertMany(dealerships_data['dealerships']);
});

} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}


// Express route to home
app.get('/', async (req, res) => {
res.send("Welcome to the Mongoose API")
// Seed data
(async () => {
try {
await Reviews.deleteMany({});
await Reviews.insertMany(reviewsData.reviews);

await Dealerships.deleteMany({});
await Dealerships.insertMany(dealershipsData.dealerships);
} catch (error) {
console.error('Error seeding database:', error);
}
})();

// Routes
app.get('/', (req, res) => {
res.send('Welcome to the Mongoose API');
});

// Express route to fetch all reviews
app.get('/fetchReviews', async (req, res) => {
try {
const documents = await Reviews.find();
Expand All @@ -46,59 +48,75 @@ app.get('/fetchReviews', async (req, res) => {
}
});

// Express route to fetch reviews by a particular dealer
app.get('/fetchReviews/dealer/:id', async (req, res) => {
try {
const documents = await Reviews.find({dealership: req.params.id});
const documents = await Reviews.find({ dealership: req.params.id });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch all dealerships
app.get('/fetchDealers', async (req, res) => {
//Write your code here
try {
const dealers = await Dealerships.find();
res.json(dealers);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealers' });
}
});

// Express route to fetch Dealers by a particular state
app.get('/fetchDealers/:state', async (req, res) => {
//Write your code here
try {
const state = req.params.state;
const dealers = await Dealerships.find({ state });
res.json(dealers);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealers by state' });
}
});

// Express route to fetch dealer by a particular id
app.get('/fetchDealer/:id', async (req, res) => {
//Write your code here
try {
const dealerId = parseInt(req.params.id, 10);
const dealer = await Dealerships.findOne({ id: dealerId });

if (!dealer) {
return res.status(404).json({ error: 'Dealer not found' });
}

res.json(dealer);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealer by ID' });
}
});

//Express route to insert review
app.post('/insert_review', express.raw({ type: '*/*' }), async (req, res) => {
data = JSON.parse(req.body);
const documents = await Reviews.find().sort( { id: -1 } )
let new_id = documents[0]['id']+1

const review = new Reviews({
"id": new_id,
"name": data['name'],
"dealership": data['dealership'],
"review": data['review'],
"purchase": data['purchase'],
"purchase_date": data['purchase_date'],
"car_make": data['car_make'],
"car_model": data['car_model'],
"car_year": data['car_year'],
});

try {
const data = JSON.parse(req.body);
const documents = await Reviews.find().sort({ id: -1 });
const newId = documents.length > 0 ? documents[0].id + 1 : 1;

const review = new Reviews({
id: newId,
name: data.name,
dealership: data.dealership,
review: data.review,
purchase: data.purchase,
purchase_date: data.purchase_date,
car_make: data.car_make,
car_model: data.car_model,
car_year: data.car_year
});

const savedReview = await review.save();
res.json(savedReview);
} catch (error) {
console.log(error);
console.error('Insert review error:', error);
res.status(500).json({ error: 'Error inserting review' });
}
});

// Start the Express server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
Loading