mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-12-23 12:15:11 +00:00
Compare commits
No commits in common. "dbc793cc0849048ee91c9419a6e41c5696f0da0a" and "d2a4d93f54fc5ecd86c3012e717a78d04b078c3a" have entirely different histories.
dbc793cc08
...
d2a4d93f54
4984
Backend/package-lock.json
generated
4984
Backend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -11,9 +11,7 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/cookie-parser": "^1.4.2",
|
|
||||||
"bcrypt": "^5.0.1",
|
"bcrypt": "^5.0.1",
|
||||||
"cookie-parser": "^1.4.5",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
|
|
@ -14,9 +14,6 @@ import {vendorsRouter} from './models/vendors/vendors.router';
|
||||||
import {errorHandler} from './middleware/error.middleware';
|
import {errorHandler} from './middleware/error.middleware';
|
||||||
import {notFoundHandler} from './middleware/notFound.middleware';
|
import {notFoundHandler} from './middleware/notFound.middleware';
|
||||||
import {usersRouter} from './models/users/users.router';
|
import {usersRouter} from './models/users/users.router';
|
||||||
import {pricealarmsRouter} from './models/pricealarms/pricealarms.router';
|
|
||||||
|
|
||||||
const cookieParser = require('cookie-parser');
|
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
@ -41,14 +38,12 @@ const app = express();
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(cookieParser());
|
|
||||||
app.use('/products', productsRouter);
|
app.use('/products', productsRouter);
|
||||||
app.use('/categories', categoriesRouter);
|
app.use('/categories', categoriesRouter);
|
||||||
app.use('/manufacturers', manufacturersRouter);
|
app.use('/manufacturers', manufacturersRouter);
|
||||||
app.use('/prices', pricesRouter);
|
app.use('/prices', pricesRouter);
|
||||||
app.use('/users', usersRouter);
|
app.use('/users', usersRouter);
|
||||||
app.use('/vendors', vendorsRouter);
|
app.use('/vendors', vendorsRouter);
|
||||||
app.use('/pricealarms', pricealarmsRouter);
|
|
||||||
|
|
||||||
app.use(errorHandler);
|
app.use(errorHandler);
|
||||||
app.use(notFoundHandler);
|
app.use(notFoundHandler);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import HttpException from '../common/http-exception';
|
import HttpException from "../common/http-exception";
|
||||||
import {Request, Response, NextFunction} from 'express';
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
|
||||||
export const errorHandler = (
|
export const errorHandler = (
|
||||||
error: HttpException,
|
error: HttpException,
|
||||||
|
@ -9,7 +9,7 @@ export const errorHandler = (
|
||||||
) => {
|
) => {
|
||||||
const status = error.statusCode || 500;
|
const status = error.statusCode || 500;
|
||||||
const message =
|
const message =
|
||||||
error.message || 'It\'s not you. It\'s us. We are having some problems.';
|
error.message || "It's not you. It's us. We are having some problems.";
|
||||||
|
|
||||||
response.status(status).send(message);
|
response.status(status).send(message);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Request, Response, NextFunction} from 'express';
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
|
||||||
export const notFoundHandler = (
|
export const notFoundHandler = (
|
||||||
request: Request,
|
request: Request,
|
||||||
|
@ -6,7 +6,7 @@ export const notFoundHandler = (
|
||||||
next: NextFunction
|
next: NextFunction
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
const message = 'Resource not found';
|
const message = "Resource not found";
|
||||||
|
|
||||||
response.status(404).send(message);
|
response.status(404).send(message);
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,7 @@ categoriesRouter.get('/', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(categories);
|
res.status(200).send(categories);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ categoriesRouter.get('/:id', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(category);
|
res.status(200).send(category);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,6 +65,6 @@ categoriesRouter.get('/search/:term', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(categories);
|
res.status(200).send(categories);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,9 +23,6 @@ import {Categories} from './categories.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known categories
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Categories> => {
|
export const findAll = async (): Promise<Categories> => {
|
||||||
let conn;
|
let conn;
|
||||||
let categRows = [];
|
let categRows = [];
|
||||||
|
@ -57,10 +54,6 @@ export const findAll = async (): Promise<Categories> => {
|
||||||
return categRows;
|
return categRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the category with the specified id
|
|
||||||
* @param id The id of the category to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Category> => {
|
export const find = async (id: number): Promise<Category> => {
|
||||||
let conn;
|
let conn;
|
||||||
let categ: any;
|
let categ: any;
|
||||||
|
@ -84,10 +77,6 @@ export const find = async (id: number): Promise<Category> => {
|
||||||
return categ;
|
return categ;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all categories that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Categories> => {
|
export const findBySearchTerm = async (term: string): Promise<Categories> => {
|
||||||
let conn;
|
let conn;
|
||||||
let categRows = [];
|
let categRows = [];
|
||||||
|
@ -111,3 +100,36 @@ export const findBySearchTerm = async (term: string): Promise<Categories> => {
|
||||||
|
|
||||||
return categRows;
|
return categRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
|
@ -27,7 +27,7 @@ manufacturersRouter.get('/', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(manufacturers);
|
res.status(200).send(manufacturers);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ manufacturersRouter.get('/:id', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(manufacturer);
|
res.status(200).send(manufacturer);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// GET items/:term
|
// GET items/:name
|
||||||
manufacturersRouter.get('/search/:term', async (req: Request, res: Response) => {
|
manufacturersRouter.get('/search/:term', async (req: Request, res: Response) => {
|
||||||
const term: string = req.params.term;
|
const term: string = req.params.term;
|
||||||
|
|
||||||
|
@ -65,6 +65,6 @@ manufacturersRouter.get('/search/:term', async (req: Request, res: Response) =>
|
||||||
res.status(200).send(manufacturer);
|
res.status(200).send(manufacturer);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,9 +23,6 @@ import {Manufacturers} from './manufacturers.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known manufacturers
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Manufacturers> => {
|
export const findAll = async (): Promise<Manufacturers> => {
|
||||||
let conn;
|
let conn;
|
||||||
let manRows = [];
|
let manRows = [];
|
||||||
|
@ -57,10 +54,6 @@ export const findAll = async (): Promise<Manufacturers> => {
|
||||||
return manRows;
|
return manRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the manufacturer with the specified id
|
|
||||||
* @param id The id of the manufacturer to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Manufacturer> => {
|
export const find = async (id: number): Promise<Manufacturer> => {
|
||||||
let conn;
|
let conn;
|
||||||
let man: any;
|
let man: any;
|
||||||
|
@ -84,10 +77,6 @@ export const find = async (id: number): Promise<Manufacturer> => {
|
||||||
return man;
|
return man;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all manufacturers that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Manufacturers> => {
|
export const findBySearchTerm = async (term: string): Promise<Manufacturers> => {
|
||||||
let conn;
|
let conn;
|
||||||
let manRows = [];
|
let manRows = [];
|
||||||
|
@ -111,3 +100,36 @@ export const findBySearchTerm = async (term: string): Promise<Manufacturers> =>
|
||||||
|
|
||||||
return manRows;
|
return manRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
export interface PriceAlarm {
|
|
||||||
alarm_id: number;
|
|
||||||
user_id: number;
|
|
||||||
product_id: number;
|
|
||||||
defined_price: number;
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
import {PriceAlarm} from './pricealarm.interface';
|
|
||||||
|
|
||||||
export interface PriceAlarms {
|
|
||||||
[key: number]: PriceAlarm;
|
|
||||||
}
|
|
|
@ -1,102 +0,0 @@
|
||||||
/**
|
|
||||||
* Required External Modules and Interfaces
|
|
||||||
*/
|
|
||||||
|
|
||||||
import express, {Request, Response} from 'express';
|
|
||||||
import * as PriceAlarmsService from './pricealarms.service';
|
|
||||||
import {PriceAlarm} from './pricealarm.interface';
|
|
||||||
import {PriceAlarms} from './pricealarms.interface';
|
|
||||||
import * as UserService from '../users/users.service';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Router Definition
|
|
||||||
*/
|
|
||||||
export const pricealarmsRouter = express.Router();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller Definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
//GET pricealarms/
|
|
||||||
pricealarmsRouter.get('/', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
|
||||||
|
|
||||||
const priceAlarms = await PriceAlarmsService.getPriceAlarms(user.user_id);
|
|
||||||
|
|
||||||
res.status(200).send(priceAlarms);
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// POST pricealarms/create
|
|
||||||
pricealarmsRouter.post('/create', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
|
||||||
|
|
||||||
// Get info for price alarm creation
|
|
||||||
const product_id = req.body.product_id;
|
|
||||||
const defined_price = req.body.defined_price;
|
|
||||||
|
|
||||||
if (!product_id || !defined_price) {
|
|
||||||
// Missing
|
|
||||||
res.status(400).send(JSON.stringify({message: 'Missing parameters'}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create price alarm
|
|
||||||
const success = await PriceAlarmsService.createPriceAlarm(user.user_id, product_id, defined_price);
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
res.status(201).send(JSON.stringify({success: true}));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
res.status(500).send(JSON.stringify({success: false}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// PUT pricealarms/update
|
|
||||||
pricealarmsRouter.put('/update', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
|
||||||
|
|
||||||
// Get info for price alarm creation
|
|
||||||
const alarm_id = req.body.alarm_id;
|
|
||||||
const defined_price = req.body.defined_price;
|
|
||||||
|
|
||||||
if (!alarm_id || !defined_price) {
|
|
||||||
// Missing
|
|
||||||
res.status(400).send(JSON.stringify({message: 'Missing parameters'}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create price alarm
|
|
||||||
const success = await PriceAlarmsService.updatePriceAlarm(alarm_id, user.user_id, defined_price);
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
res.status(201).send(JSON.stringify({success: true}));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
res.status(500).send(JSON.stringify({success: false}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,106 +0,0 @@
|
||||||
import * as dotenv from 'dotenv';
|
|
||||||
|
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
const mariadb = require('mariadb');
|
|
||||||
const pool = mariadb.createPool({
|
|
||||||
host: process.env.DB_HOST,
|
|
||||||
user: process.env.DB_USER,
|
|
||||||
password: process.env.DB_PASSWORD,
|
|
||||||
database: process.env.DB_DATABASE,
|
|
||||||
connectionLimit: 5
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data Model Interfaces
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {PriceAlarm} from './pricealarm.interface';
|
|
||||||
import {PriceAlarms} from './pricealarms.interface';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service Methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a price alarm for the given user for the product with the defined price
|
|
||||||
* @param user_id The id of the user to create the price alarm for
|
|
||||||
* @param product_id The id of the product to create the price alarm for
|
|
||||||
* @param defined_price The defined price for the price alarm
|
|
||||||
*/
|
|
||||||
export const createPriceAlarm = async (user_id: number, product_id: number, defined_price: number): Promise<Boolean> => {
|
|
||||||
let conn;
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
const res = await conn.query('INSERT INTO price_alarms (user_id, product_id, defined_price) VALUES (?, ?, ?)', [user_id, product_id, defined_price]);
|
|
||||||
|
|
||||||
if (res.affectedRows === 1) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all price alarms for the given user
|
|
||||||
* @param user_id
|
|
||||||
*/
|
|
||||||
export const getPriceAlarms = async (user_id: number): Promise<PriceAlarms> => {
|
|
||||||
let conn;
|
|
||||||
let priceAlarms = [];
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
const rows = await conn.query('SELECT alarm_id, user_id, product_id, defined_price FROM price_alarms WHERE user_id = ?', user_id);
|
|
||||||
for (let row in rows) {
|
|
||||||
if (row !== 'meta') {
|
|
||||||
priceAlarms.push(rows[row]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return priceAlarms;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the given price alarm with the given fields
|
|
||||||
* @param alarm_id The id of the price alarm to update
|
|
||||||
* @param user_id The id of the user that wants to update the price alarm
|
|
||||||
* @param defined_price The defined price for the price alarm
|
|
||||||
*/
|
|
||||||
export const updatePriceAlarm = async (alarm_id: number, user_id: number, defined_price: number): Promise<Boolean> => {
|
|
||||||
let conn;
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
const res = await conn.query('UPDATE price_alarms SET defined_price = ? WHERE alarm_id = ? AND user_id = ?', [defined_price, alarm_id, user_id]);
|
|
||||||
|
|
||||||
if (res.affectedRows === 1) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
|
@ -40,7 +40,7 @@ pricesRouter.get('/', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(prices);
|
res.status(200).send(prices);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ pricesRouter.get('/:id', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(price);
|
res.status(200).send(price);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ pricesRouter.get('/bestDeals/:amount', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(prices);
|
res.status(200).send(prices);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -97,6 +97,6 @@ pricesRouter.get('/byProduct/list/:ids', async (req: Request, res: Response) =>
|
||||||
res.status(200).send(prices);
|
res.status(200).send(prices);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,15 +23,12 @@ import {Prices} from './prices.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known prices
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Prices> => {
|
export const findAll = async (): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
try {
|
try {
|
||||||
conn = await pool.getConnection();
|
conn = await pool.getConnection();
|
||||||
const rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE active_listing = true');
|
const rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices');
|
||||||
for (let row in rows) {
|
for (let row in rows) {
|
||||||
if (row !== 'meta') {
|
if (row !== 'meta') {
|
||||||
let price: Price = {
|
let price: Price = {
|
||||||
|
@ -63,16 +60,12 @@ export const findAll = async (): Promise<Prices> => {
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the price with the specified id
|
|
||||||
* @param id The id of the price to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Price> => {
|
export const find = async (id: number): Promise<Price> => {
|
||||||
let conn;
|
let conn;
|
||||||
let price: any;
|
let price: any;
|
||||||
try {
|
try {
|
||||||
conn = await pool.getConnection();
|
conn = await pool.getConnection();
|
||||||
const rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE price_id = ? AND active_listing = true', id);
|
const rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE price_id = ?', id);
|
||||||
for (let row in rows) {
|
for (let row in rows) {
|
||||||
if (row !== 'meta') {
|
if (row !== 'meta') {
|
||||||
price = rows[row];
|
price = rows[row];
|
||||||
|
@ -90,16 +83,12 @@ export const find = async (id: number): Promise<Price> => {
|
||||||
return price;
|
return price;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all prices that belong to the specified product
|
|
||||||
* @param product the product to fetch the prices for
|
|
||||||
*/
|
|
||||||
export const findByProduct = async (product: number): Promise<Prices> => {
|
export const findByProduct = async (product: number): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
try {
|
try {
|
||||||
conn = await pool.getConnection();
|
conn = await pool.getConnection();
|
||||||
const rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ? AND active_listing = true', product);
|
const rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ?', product);
|
||||||
for (let row in rows) {
|
for (let row in rows) {
|
||||||
if (row !== 'meta') {
|
if (row !== 'meta') {
|
||||||
priceRows.push(rows[row]);
|
priceRows.push(rows[row]);
|
||||||
|
@ -117,14 +106,6 @@ export const findByProduct = async (product: number): Promise<Prices> => {
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns prices that belong to the specified product.
|
|
||||||
* If type is newest, only the newest prices for each vendor will be returned.
|
|
||||||
* If type is lowest, the lowest daily price for the product is returned.
|
|
||||||
* Otherwise, all prices for this product are returned.
|
|
||||||
* @param product The product to fetch the prices for
|
|
||||||
* @param type The type of prices, e.g. newest / lowest
|
|
||||||
*/
|
|
||||||
export const findByType = async (product: string, type: string): Promise<Prices> => {
|
export const findByType = async (product: string, type: string): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -142,16 +123,16 @@ export const findByType = async (product: string, type: string): Promise<Prices>
|
||||||
'PARTITION BY p.vendor_id ' +
|
'PARTITION BY p.vendor_id ' +
|
||||||
'ORDER BY p.timestamp DESC) AS rk ' +
|
'ORDER BY p.timestamp DESC) AS rk ' +
|
||||||
'FROM prices p ' +
|
'FROM prices p ' +
|
||||||
'WHERE product_id = ? AND vendor_id != 1 AND active_listing = true) ' +
|
'WHERE product_id = ? AND vendor_id != 1) ' +
|
||||||
'SELECT s.* ' +
|
'SELECT s.* ' +
|
||||||
'FROM summary s ' +
|
'FROM summary s ' +
|
||||||
'WHERE s.rk = 1 '), product);
|
'WHERE s.rk = 1 '), product);
|
||||||
} else if (type === 'lowest') {
|
} else if (type === 'lowest') {
|
||||||
// Used to get the lowest prices for this product over a period of time
|
// Used to get the lowest prices for this product over a period of time
|
||||||
rows = await conn.query('SELECT price_id, product_id, vendor_id, MIN(price_in_cents) as price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id != 1 AND active_listing = true GROUP BY DAY(timestamp) ORDER BY timestamp', product);
|
rows = await conn.query('SELECT price_id, product_id, vendor_id, MIN(price_in_cents) as price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id != 1 GROUP BY DAY(timestamp) ORDER BY timestamp', product);
|
||||||
} else {
|
} else {
|
||||||
// If no type is given, return all prices for this product
|
// If no type is given, return all prices for this product
|
||||||
rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id != 1 AND active_listing = true', product);
|
rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id != 1', product);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let row in rows) {
|
for (let row in rows) {
|
||||||
|
@ -171,15 +152,6 @@ export const findByType = async (product: string, type: string): Promise<Prices>
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns prices that belong to the specified product and vendor.
|
|
||||||
* If type is newest, only the newest known price for the product at the vendor is returned.
|
|
||||||
* If type is lowest, only the lowest ever known price for the product at the vendor is returned.
|
|
||||||
* Otherwise, all prices for this product are returned.
|
|
||||||
* @param product The product to fetch the prices for
|
|
||||||
* @param vendor The vendor to fetch the prices for
|
|
||||||
* @param type The type of prices, e.g. newest / lowest
|
|
||||||
*/
|
|
||||||
export const findByVendor = async (product: string, vendor: string, type: string): Promise<Prices> => {
|
export const findByVendor = async (product: string, vendor: string, type: string): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -188,13 +160,13 @@ export const findByVendor = async (product: string, vendor: string, type: string
|
||||||
let rows = [];
|
let rows = [];
|
||||||
if (type === 'newest') {
|
if (type === 'newest') {
|
||||||
// Used to get the newest price for this product and vendor
|
// Used to get the newest price for this product and vendor
|
||||||
rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id = ? AND active_listing = true ORDER BY timestamp DESC LIMIT 1', [product, vendor]);
|
rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id = ? ORDER BY timestamp DESC LIMIT 1', [product, vendor]);
|
||||||
} else if (type === 'lowest') {
|
} else if (type === 'lowest') {
|
||||||
// Used to get the lowest prices for this product and vendor in all time
|
// Used to get the lowest prices for this product and vendor in all time
|
||||||
rows = await conn.query('SELECT price_id, product_id, vendor_id, MIN(price_in_cents) as price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id = ? AND active_listing = true LIMIT 1', [product, vendor]);
|
rows = await conn.query('SELECT price_id, product_id, vendor_id, MIN(price_in_cents) as price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id = ? LIMIT 1', [product, vendor]);
|
||||||
} else {
|
} else {
|
||||||
// If no type is given, return all prices for this product and vendor
|
// If no type is given, return all prices for this product and vendor
|
||||||
rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id = ? AND active_listing = true', [product, vendor]);
|
rows = await conn.query('SELECT price_id, product_id, vendor_id, price_in_cents, timestamp FROM prices WHERE product_id = ? AND vendor_id = ?', [product, vendor]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let row in rows) {
|
for (let row in rows) {
|
||||||
|
@ -214,11 +186,6 @@ export const findByVendor = async (product: string, vendor: string, type: string
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the best current deals, i.e. the non-amazon prices that have the biggest difference to amazon prices.
|
|
||||||
* Only the latest known prices for every vendor are taken into consideration so we only get up-to-date-deals.
|
|
||||||
* @param amount The amount of deals to return
|
|
||||||
*/
|
|
||||||
export const getBestDeals = async (amount: number): Promise<Prices> => {
|
export const getBestDeals = async (amount: number): Promise<Prices> => {
|
||||||
let conn;
|
let conn;
|
||||||
let priceRows = [];
|
let priceRows = [];
|
||||||
|
@ -237,7 +204,7 @@ export const getBestDeals = async (amount: number): Promise<Prices> => {
|
||||||
' ROW_NUMBER() OVER(\n' +
|
' ROW_NUMBER() OVER(\n' +
|
||||||
' PARTITION BY p.product_id, p.vendor_id\n' +
|
' PARTITION BY p.product_id, p.vendor_id\n' +
|
||||||
' ORDER BY p.timestamp DESC) AS rk\n' +
|
' ORDER BY p.timestamp DESC) AS rk\n' +
|
||||||
' FROM prices p WHERE active_listing = true)\n' +
|
' FROM prices p)\n' +
|
||||||
'SELECT s.*\n' +
|
'SELECT s.*\n' +
|
||||||
'FROM summary s\n' +
|
'FROM summary s\n' +
|
||||||
'WHERE s.rk = 1');
|
'WHERE s.rk = 1');
|
||||||
|
@ -298,6 +265,7 @@ export const getBestDeals = async (amount: number): Promise<Prices> => {
|
||||||
let maxAmt = Math.min(amount, deals.length);
|
let maxAmt = Math.min(amount, deals.length);
|
||||||
|
|
||||||
for (let dealIndex = 0; dealIndex < maxAmt; dealIndex++) {
|
for (let dealIndex = 0; dealIndex < maxAmt; dealIndex++) {
|
||||||
|
//console.log(deals[dealIndex]);
|
||||||
priceRows.push(deals[dealIndex] as Price);
|
priceRows.push(deals[dealIndex] as Price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +282,7 @@ export const getBestDeals = async (amount: number): Promise<Prices> => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches and returns the lowest, latest, non-amazon price for each given product
|
* Get the lowest, latest, non-amazon price for each given product
|
||||||
* @param ids the ids of the products
|
* @param ids the ids of the products
|
||||||
*/
|
*/
|
||||||
export const findListByProducts = async (productIds: [number]): Promise<Prices> => {
|
export const findListByProducts = async (productIds: [number]): Promise<Prices> => {
|
||||||
|
@ -337,7 +305,7 @@ export const findListByProducts = async (productIds: [number]): Promise<Prices>
|
||||||
' ORDER BY p.timestamp DESC) AS rk\n' +
|
' ORDER BY p.timestamp DESC) AS rk\n' +
|
||||||
' FROM prices p' +
|
' FROM prices p' +
|
||||||
' WHERE p.product_id IN (?)' +
|
' WHERE p.product_id IN (?)' +
|
||||||
' AND p.vendor_id != 1 AND active_listing = true)\n' +
|
' AND p.vendor_id != 1)\n' +
|
||||||
'SELECT s.*\n' +
|
'SELECT s.*\n' +
|
||||||
'FROM summary s\n' +
|
'FROM summary s\n' +
|
||||||
'WHERE s.rk = 1', [productIds]);
|
'WHERE s.rk = 1', [productIds]);
|
||||||
|
@ -376,3 +344,36 @@ export const findListByProducts = async (productIds: [number]): Promise<Prices>
|
||||||
|
|
||||||
return priceRows;
|
return priceRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
|
@ -27,7 +27,7 @@ productsRouter.get('/', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(products);
|
res.status(200).send(products);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ productsRouter.get('/:id', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(product);
|
res.status(200).send(product);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ productsRouter.get('/search/:term', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(products);
|
res.status(200).send(products);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -84,6 +84,6 @@ productsRouter.get('/list/:ids', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(products);
|
res.status(200).send(products);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,9 +23,6 @@ import {Products} from './products.interface';
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known products
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Products> => {
|
export const findAll = async (): Promise<Products> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prodRows = [];
|
let prodRows = [];
|
||||||
|
@ -77,10 +74,6 @@ export const findAll = async (): Promise<Products> => {
|
||||||
return prodRows;
|
return prodRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the product with the specified id
|
|
||||||
* @param id The id of the product to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Product> => {
|
export const find = async (id: number): Promise<Product> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prod: any;
|
let prod: any;
|
||||||
|
@ -104,10 +97,6 @@ export const find = async (id: number): Promise<Product> => {
|
||||||
return prod;
|
return prod;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all products that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Products> => {
|
export const findBySearchTerm = async (term: string): Promise<Products> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prodRows = [];
|
let prodRows = [];
|
||||||
|
@ -133,10 +122,6 @@ export const findBySearchTerm = async (term: string): Promise<Products> => {
|
||||||
return prodRows;
|
return prodRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the product details for the given list of product ids
|
|
||||||
* @param ids The list of product ids to fetch the details for
|
|
||||||
*/
|
|
||||||
export const findList = async (ids: [number]): Promise<Products> => {
|
export const findList = async (ids: [number]): Promise<Products> => {
|
||||||
let conn;
|
let conn;
|
||||||
let prodRows = [];
|
let prodRows = [];
|
||||||
|
@ -159,3 +144,36 @@ export const findList = async (ids: [number]): Promise<Products> => {
|
||||||
|
|
||||||
return prodRows;
|
return prodRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
|
// let conn;
|
||||||
|
// try {
|
||||||
|
// conn = await pool.getConnection();
|
||||||
|
// await conn.query("");
|
||||||
|
//
|
||||||
|
// } catch (err) {
|
||||||
|
// throw err;
|
||||||
|
// } finally {
|
||||||
|
// if (conn) conn.end();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to update");
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
|
//
|
||||||
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// throw new Error("No record found to delete");
|
||||||
|
// };
|
||||||
|
|
|
@ -47,13 +47,10 @@ usersRouter.post('/register', async (req: Request, res: Response) => {
|
||||||
const session: Session = await UserService.createUser(username, password, email, ip);
|
const session: Session = await UserService.createUser(username, password, email, ip);
|
||||||
|
|
||||||
// Send the session details back to the user
|
// Send the session details back to the user
|
||||||
res.cookie('betterauth', JSON.stringify({
|
res.status(201).send(session);
|
||||||
id: session.session_id,
|
|
||||||
key: session.session_key
|
|
||||||
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).sendStatus(201);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,34 +70,39 @@ usersRouter.post('/login', async (req: Request, res: Response) => {
|
||||||
// Update the user entry and create a session
|
// Update the user entry and create a session
|
||||||
const session: Session = await UserService.login(username, password, ip);
|
const session: Session = await UserService.login(username, password, ip);
|
||||||
|
|
||||||
if (!session.session_id) {
|
if(!session.session_id) {
|
||||||
// Error logging in, probably wrong username / password
|
// Error logging in, probably wrong username / password
|
||||||
res.status(401).send(JSON.stringify({messages: ['Wrong username and / or password'], codes: [1, 4]}));
|
res.status(401).send(JSON.stringify({messages: ["Wrong username and / or password"], codes: [1, 4]}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the session details back to the user
|
// Send the session details back to the user
|
||||||
res.cookie('betterauth', JSON.stringify({
|
res.status(201).send(session);
|
||||||
id: session.session_id,
|
|
||||||
key: session.session_key
|
|
||||||
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).sendStatus(200);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST users/checkSessionValid
|
// POST users/checkSessionValid
|
||||||
usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
|
usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
|
const sessionId: string = req.body.sessionId;
|
||||||
|
const sessionKey: string = req.body.sessionKey;
|
||||||
const ip: string = req.connection.remoteAddress ?? '';
|
const ip: string = req.connection.remoteAddress ?? '';
|
||||||
|
|
||||||
// Update the user entry and create a session
|
if (!sessionId || !sessionKey) {
|
||||||
const user: User = await UserService.checkSessionWithCookie(req.cookies.betterauth, ip);
|
// Missing
|
||||||
|
res.status(400).send(JSON.stringify({message: 'Missing parameters'}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!user.user_id) {
|
// Update the user entry and create a session
|
||||||
|
const user: User = await UserService.checkSession(sessionId, sessionKey, ip);
|
||||||
|
|
||||||
|
if(!user.user_id) {
|
||||||
// Error logging in, probably wrong username / password
|
// Error logging in, probably wrong username / password
|
||||||
res.status(401).send(JSON.stringify({messages: ['Invalid session'], codes: [5]}));
|
res.status(401).send(JSON.stringify({messages: ["Invalid session"], codes: [5]}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +110,6 @@ usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
|
||||||
res.status(201).send(user);
|
res.status(201).send(user);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -68,7 +68,7 @@ export const createUser = async (username: string, password: string, email: stri
|
||||||
return {
|
return {
|
||||||
session_id: sessionId,
|
session_id: sessionId,
|
||||||
session_key: sessionKey,
|
session_key: sessionKey,
|
||||||
session_key_hash: 'HIDDEN',
|
session_key_hash: '',
|
||||||
last_IP: ip
|
last_IP: ip
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ export const login = async (username: string, password: string, ip: string): Pro
|
||||||
return {
|
return {
|
||||||
session_id: sessionId,
|
session_id: sessionId,
|
||||||
session_key: sessionKey,
|
session_key: sessionKey,
|
||||||
session_key_hash: 'HIDDEN',
|
session_key_hash: '',
|
||||||
last_IP: ip
|
last_IP: ip
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ export const checkSession = async (sessionId: string, sessionKey: string, ip: st
|
||||||
// Key is valid, continue
|
// Key is valid, continue
|
||||||
|
|
||||||
// Check if the session is still valid
|
// Check if the session is still valid
|
||||||
if (validUntil <= new Date()) {
|
if(validUntil <= new Date()) {
|
||||||
// Session expired, return invalid
|
// Session expired, return invalid
|
||||||
return {} as User;
|
return {} as User;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ export const checkSession = async (sessionId: string, sessionKey: string, ip: st
|
||||||
await conn.commit();
|
await conn.commit();
|
||||||
|
|
||||||
// Get the other required user information and update the user
|
// Get the other required user information and update the user
|
||||||
const userQuery = 'SELECT user_id, username, email, registration_date, last_login_date FROM users WHERE user_id = ?';
|
const userQuery = "SELECT user_id, username, email, registration_date, last_login_date FROM users WHERE user_id = ?";
|
||||||
const userRows = await conn.query(userQuery, userId);
|
const userRows = await conn.query(userQuery, userId);
|
||||||
let username = '';
|
let username = '';
|
||||||
let email = '';
|
let email = '';
|
||||||
|
@ -213,7 +213,7 @@ export const checkSession = async (sessionId: string, sessionKey: string, ip: st
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
username: username,
|
username: username,
|
||||||
email: email,
|
email: email,
|
||||||
password_hash: 'HIDDEN',
|
password_hash: '',
|
||||||
registration_date: registrationDate,
|
registration_date: registrationDate,
|
||||||
last_login_date: lastLoginDate
|
last_login_date: lastLoginDate
|
||||||
};
|
};
|
||||||
|
@ -229,20 +229,6 @@ export const checkSession = async (sessionId: string, sessionKey: string, ip: st
|
||||||
return {} as User;
|
return {} as User;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls the checkSession method after extracting the required information from the authentication cookie
|
|
||||||
* @param cookie The betterauth cookie
|
|
||||||
* @param ip The users IP address
|
|
||||||
*/
|
|
||||||
export const checkSessionWithCookie = async (cookie: any, ip: string): Promise<User> => {
|
|
||||||
const parsedCookie = JSON.parse(cookie);
|
|
||||||
const session_id = parsedCookie.id;
|
|
||||||
const session_key = parsedCookie.key;
|
|
||||||
|
|
||||||
|
|
||||||
return checkSession(session_id, session_key, '');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in the checkUsernameAndEmail method as return value
|
* Used in the checkUsernameAndEmail method as return value
|
||||||
*/
|
*/
|
||||||
|
|
53
Backend/src/models/vendors/vendors.router.ts
vendored
53
Backend/src/models/vendors/vendors.router.ts
vendored
|
@ -6,7 +6,6 @@ import express, {Request, Response} from 'express';
|
||||||
import * as VendorService from './vendors.service';
|
import * as VendorService from './vendors.service';
|
||||||
import {Vendor} from './vendor.interface';
|
import {Vendor} from './vendor.interface';
|
||||||
import {Vendors} from './vendors.interface';
|
import {Vendors} from './vendors.interface';
|
||||||
import * as UserService from '../users/users.service';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +19,7 @@ export const vendorsRouter = express.Router();
|
||||||
* Controller Definitions
|
* Controller Definitions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// GET vendors/
|
// GET items/
|
||||||
vendorsRouter.get('/', async (req: Request, res: Response) => {
|
vendorsRouter.get('/', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const vendors: Vendors = await VendorService.findAll();
|
const vendors: Vendors = await VendorService.findAll();
|
||||||
|
@ -28,27 +27,11 @@ vendorsRouter.get('/', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(vendors);
|
res.status(200).send(vendors);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// GET vendors/managed
|
// GET items/:id
|
||||||
vendorsRouter.get('/managed', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
|
||||||
|
|
||||||
const vendors = await VendorService.getManagedShops(user.user_id);
|
|
||||||
|
|
||||||
res.status(200).send(vendors);
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// GET vendors/:id
|
|
||||||
vendorsRouter.get('/:id', async (req: Request, res: Response) => {
|
vendorsRouter.get('/:id', async (req: Request, res: Response) => {
|
||||||
const id: number = parseInt(req.params.id, 10);
|
const id: number = parseInt(req.params.id, 10);
|
||||||
|
|
||||||
|
@ -63,11 +46,11 @@ vendorsRouter.get('/:id', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(vendor);
|
res.status(200).send(vendor);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// GET vendors/search/:term
|
// GET items/:name
|
||||||
vendorsRouter.get('/search/:term', async (req: Request, res: Response) => {
|
vendorsRouter.get('/search/:term', async (req: Request, res: Response) => {
|
||||||
const term: string = req.params.term;
|
const term: string = req.params.term;
|
||||||
|
|
||||||
|
@ -82,30 +65,6 @@ vendorsRouter.get('/search/:term', async (req: Request, res: Response) => {
|
||||||
res.status(200).send(vendors);
|
res.status(200).send(vendors);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({"message": "Internal Server Error. Try again later."}));
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// PUT /manage/deactivatelisting
|
|
||||||
vendorsRouter.put('/manage/deactivatelisting', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
|
||||||
|
|
||||||
// Get required parameters
|
|
||||||
const vendor_id = req.body.vendor_id;
|
|
||||||
const product_id = req.body.product_id;
|
|
||||||
|
|
||||||
const success = await VendorService.deactivateListing(user.user_id, vendor_id, product_id);
|
|
||||||
|
|
||||||
if(success) {
|
|
||||||
res.sendStatus(200);
|
|
||||||
} else {
|
|
||||||
res.sendStatus(500);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
104
Backend/src/models/vendors/vendors.service.ts
vendored
104
Backend/src/models/vendors/vendors.service.ts
vendored
|
@ -17,16 +17,12 @@ const pool = mariadb.createPool({
|
||||||
|
|
||||||
import {Vendor} from './vendor.interface';
|
import {Vendor} from './vendor.interface';
|
||||||
import {Vendors} from './vendors.interface';
|
import {Vendors} from './vendors.interface';
|
||||||
import {User} from '../users/user.interface';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service Methods
|
* Service Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all known vendors
|
|
||||||
*/
|
|
||||||
export const findAll = async (): Promise<Vendors> => {
|
export const findAll = async (): Promise<Vendors> => {
|
||||||
let conn;
|
let conn;
|
||||||
let vendorRows = [];
|
let vendorRows = [];
|
||||||
|
@ -70,10 +66,6 @@ export const findAll = async (): Promise<Vendors> => {
|
||||||
return vendorRows;
|
return vendorRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the vendor with the specified id
|
|
||||||
* @param id The id of the vendor to fetch
|
|
||||||
*/
|
|
||||||
export const find = async (id: number): Promise<Vendor> => {
|
export const find = async (id: number): Promise<Vendor> => {
|
||||||
let conn;
|
let conn;
|
||||||
let vendor: any;
|
let vendor: any;
|
||||||
|
@ -97,10 +89,6 @@ export const find = async (id: number): Promise<Vendor> => {
|
||||||
return vendor;
|
return vendor;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all vendors that match the search term
|
|
||||||
* @param term the term to match
|
|
||||||
*/
|
|
||||||
export const findBySearchTerm = async (term: string): Promise<Vendors> => {
|
export const findBySearchTerm = async (term: string): Promise<Vendors> => {
|
||||||
let conn;
|
let conn;
|
||||||
let vendorRows = [];
|
let vendorRows = [];
|
||||||
|
@ -125,63 +113,35 @@ export const findBySearchTerm = async (term: string): Promise<Vendors> => {
|
||||||
return vendorRows;
|
return vendorRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
// export const create = async (newItem: Product): Promise<void> => {
|
||||||
* Get all vendors that have the given user as admin
|
// let conn;
|
||||||
* @param user The user to return the managed shops for
|
// try {
|
||||||
*/
|
// conn = await pool.getConnection();
|
||||||
export const getManagedShops = async (user_id: number): Promise<Vendors> => {
|
// await conn.query("");
|
||||||
let conn;
|
//
|
||||||
let vendorRows = [];
|
// } catch (err) {
|
||||||
try {
|
// throw err;
|
||||||
conn = await pool.getConnection();
|
// } finally {
|
||||||
const rows = await conn.query('SELECT vendor_id, name, streetname, zip_code, city, country_code, phone, website FROM vendors WHERE admin_id LIKE ?', user_id);
|
// if (conn) conn.end();
|
||||||
for (let row in rows) {
|
// }
|
||||||
if (row !== 'meta') {
|
// };
|
||||||
vendorRows.push(rows[row]);
|
//
|
||||||
}
|
// export const update = async (updatedItem: Product): Promise<void> => {
|
||||||
}
|
// if (models.products[updatedItem.product_id]) {
|
||||||
|
// models.products[updatedItem.product_id] = updatedItem;
|
||||||
} catch (err) {
|
// return;
|
||||||
throw err;
|
// }
|
||||||
} finally {
|
//
|
||||||
if (conn) {
|
// throw new Error("No record found to update");
|
||||||
conn.end();
|
// };
|
||||||
}
|
//
|
||||||
}
|
// export const remove = async (id: number): Promise<void> => {
|
||||||
|
// const record: Product = models.products[id];
|
||||||
return vendorRows;
|
//
|
||||||
};
|
// if (record) {
|
||||||
|
// delete models.products[id];
|
||||||
/**
|
// return;
|
||||||
* Deactivates a product listing for a specific vendor
|
// }
|
||||||
* @param user_id The user id of the issuing user
|
//
|
||||||
* @param vendor_id The vendor id of the vendor to deactivate the listing for
|
// throw new Error("No record found to delete");
|
||||||
* @param product_id The product id of the product to deactivate the listing for
|
// };
|
||||||
*/
|
|
||||||
export const deactivateListing = async (user_id: number, vendor_id: number, product_id: number): Promise<Boolean> => {
|
|
||||||
let conn;
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
|
|
||||||
// Check if the user is authorized to manage the requested vendor
|
|
||||||
const user_vendor_rows = await conn.query('SELECT vendor_id FROM vendors WHERE vendor_id = ? AND admin_id = ?', [vendor_id, user_id]);
|
|
||||||
if (user_vendor_rows.length !== 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const status = await conn.query('UPDATE prices SET active_listing = false WHERE vendor_id = ? and product_id = ?', [vendor_id, product_id]);
|
|
||||||
|
|
||||||
if(status.affectedRows > 0){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
const webpack = require('webpack');
|
const webpack = require("webpack");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
const nodeExternals = require('webpack-node-externals');
|
const nodeExternals = require("webpack-node-externals");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: ['webpack/hot/poll?100', './src/index.ts'],
|
entry: ["webpack/hot/poll?100", "./src/index.ts"],
|
||||||
watch: false,
|
watch: false,
|
||||||
target: 'node',
|
target: "node",
|
||||||
externals: [
|
externals: [
|
||||||
nodeExternals({
|
nodeExternals({
|
||||||
whitelist: ['webpack/hot/poll?100']
|
whitelist: ["webpack/hot/poll?100"]
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /.tsx?$/,
|
test: /.tsx?$/,
|
||||||
use: 'ts-loader',
|
use: "ts-loader",
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
mode: 'development',
|
mode: "development",
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.tsx', '.ts', '.js']
|
extensions: [".tsx", ".ts", ".js"]
|
||||||
},
|
},
|
||||||
plugins: [new webpack.HotModuleReplacementPlugin()],
|
plugins: [new webpack.HotModuleReplacementPlugin()],
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'dist'),
|
path: path.join(__dirname, "dist"),
|
||||||
filename: 'index.js'
|
filename: "index.js"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="Python" name="Python">
|
<facet type="Python" name="Python">
|
||||||
<configuration sdkName="Python 3.9 (venv)" />
|
<configuration sdkName="Python 3.9" />
|
||||||
</facet>
|
</facet>
|
||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="Python 3.9 (venv) interpreter library" level="application" />
|
<orderEntry type="library" name="Python 3.9 interpreter library" level="application" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,5 +1,4 @@
|
||||||
import sql
|
import sql
|
||||||
import amazonspider
|
|
||||||
|
|
||||||
|
|
||||||
def crawl(product_ids: [int]) -> dict:
|
def crawl(product_ids: [int]) -> dict:
|
||||||
|
@ -51,14 +50,13 @@ def crawl(product_ids: [int]) -> dict:
|
||||||
'products_with_problems': products_with_problems
|
'products_with_problems': products_with_problems
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def __crawl_amazon__(product_info: dict) -> tuple:
|
def __crawl_amazon__(product_info: dict) -> tuple:
|
||||||
"""
|
"""
|
||||||
Crawls the price for the given product from amazon
|
Crawls the price for the given product from amazon
|
||||||
:param product_info: A dict with product info containing product_id, vendor_id, url
|
:param product_info: A dict with product info containing product_id, vendor_id, url
|
||||||
:return: A tuple with the crawled data, containing (product_id, vendor_id, price_in_cents)
|
:return: A tuple with the crawled data, containing (product_id, vendor_id, price_in_cents)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
amazonspider.start_crawling()
|
|
||||||
return (product_info['product_id'], product_info['vendor_id'], 123)
|
return (product_info['product_id'], product_info['vendor_id'], 123)
|
||||||
|
|
||||||
|
|
||||||
|
|
0
Crawler/crawler/amazonspider.py
Normal file
0
Crawler/crawler/amazonspider.py
Normal file
|
@ -1,33 +0,0 @@
|
||||||
import scrapy
|
|
||||||
from scrapy.crawler import CrawlerProcess
|
|
||||||
import re
|
|
||||||
|
|
||||||
class AmazonSpider(scrapy.Spider):
|
|
||||||
name = 'amazon'
|
|
||||||
allowed_domains = ['amazon.de']
|
|
||||||
start_urls = ['https://amazon.de/dp/B083DRCPJG']
|
|
||||||
|
|
||||||
# def __init__(self, start_urls):
|
|
||||||
# self.start_urls = start_urls
|
|
||||||
|
|
||||||
def parse(self, response):
|
|
||||||
price = response.xpath('//*[@id="priceblock_ourprice"]/text()').extract_first()
|
|
||||||
if not price:
|
|
||||||
price = response.xpath('//*[@data-asin-price]/@data-asin-price').extract_first() or \
|
|
||||||
response.xpath('//*[@id="price_inside_buybox"]/text()').extract_first()
|
|
||||||
|
|
||||||
euros = re.match('(\d*),\d\d', price).group(1)
|
|
||||||
cents = re.match('\d*,(\d\d)', price).group(1)
|
|
||||||
priceincents = euros + cents
|
|
||||||
|
|
||||||
yield {'price': priceincents}
|
|
||||||
|
|
||||||
|
|
||||||
def start_crawling():
|
|
||||||
process = CrawlerProcess(
|
|
||||||
settings={'COOKIES_ENABLED': 'False', 'CONCURRENT_REQUESTS_PER_IP': 1, 'ROBOTSTXT_OBEY': False,
|
|
||||||
'USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
|
||||||
'DOWNLOAD_DELAY': 3}
|
|
||||||
, install_root_handler=False)
|
|
||||||
process.crawl()
|
|
||||||
process.start()
|
|
|
@ -1,25 +0,0 @@
|
||||||
import scrapy
|
|
||||||
import re
|
|
||||||
|
|
||||||
class AmazonSpider(scrapy.Spider):
|
|
||||||
name = 'amazon'
|
|
||||||
allowed_domains = ['amazon.de']
|
|
||||||
start_urls = ['https://amazon.de/dp/B083DRCPJG']
|
|
||||||
|
|
||||||
def parse(self, response):
|
|
||||||
price = response.xpath('//*[@id="priceblock_ourprice"]/text()').extract_first()
|
|
||||||
if not price:
|
|
||||||
price = response.xpath('//*[@data-asin-price]/@data-asin-price').extract_first() or \
|
|
||||||
response.xpath('//*[@id="price_inside_buybox"]/text()').extract_first()
|
|
||||||
|
|
||||||
euros = re.match('(\d*),\d\d', price).group(1)
|
|
||||||
cents = re.match('\d*,(\d\d)', price).group(1)
|
|
||||||
priceincents = euros + cents
|
|
||||||
|
|
||||||
yield {'price': priceincents}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,24 +10,17 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resource" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resource" type="java-resource" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="openjdk-16" jdkType="JavaSDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: io.cucumber:cucumber-java:2.3.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: io.cucumber:cucumber-core:2.3.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: info.cukes:cucumber-html:0.2.6" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: io.cucumber:cucumber-jvm-deps:1.0.6" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: io.cucumber:gherkin:5.0.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: io.cucumber:tag-expressions:1.1.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: io.cucumber:cucumber-junit:2.3.1" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:cucumber-java:6.10.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:cucumber-core:6.10.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:cucumber-gherkin:6.10.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:cucumber-gherkin-messages:6.10.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:messages:15.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:tag-expressions:3.0.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:cucumber-expressions:10.3.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:datatable:3.5.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:cucumber-plugin:6.10.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:docstring:6.10.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:html-formatter:13.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:create-meta:4.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apiguardian:apiguardian-api:1.1.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.cucumber:cucumber-junit:6.10.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apache.maven.plugins:maven-compiler-plugin:3.8.1" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.maven.plugins:maven-compiler-plugin:3.8.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.apache.maven:maven-plugin-api:3.0" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.maven:maven-plugin-api:3.0" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.apache.maven:maven-model:3.0" level="project" />
|
<orderEntry type="library" name="Maven: org.apache.maven:maven-model:3.0" level="project" />
|
||||||
|
@ -60,25 +53,5 @@
|
||||||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-compiler-api:2.8.4" level="project" />
|
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-compiler-api:2.8.4" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-compiler-manager:2.8.4" level="project" />
|
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-compiler-manager:2.8.4" level="project" />
|
||||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.plexus:plexus-compiler-javac:2.8.4" level="project" />
|
<orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.plexus:plexus-compiler-javac:2.8.4" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-java:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-api:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-chrome-driver:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-edge-driver:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-firefox-driver:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-ie-driver:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-opera-driver:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-remote-driver:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-safari-driver:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-support:3.141.59" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.8.15" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-exec:1.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:25.0-jre" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.1.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.11.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.14.0" level="project" />
|
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -4,7 +4,7 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>xyz.betterzon</groupId>
|
<groupId>de.taskhub</groupId>
|
||||||
<artifactId>CucumberTests</artifactId>
|
<artifactId>CucumberTests</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -13,30 +13,21 @@
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>io.cucumber</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>cucumber-java</artifactId>
|
||||||
<version>4.12</version>
|
<version>2.3.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.cucumber</groupId>
|
|
||||||
<artifactId>cucumber-java</artifactId>
|
|
||||||
<version>6.10.3</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.cucumber</groupId>
|
<groupId>io.cucumber</groupId>
|
||||||
<artifactId>cucumber-junit</artifactId>
|
<artifactId>cucumber-junit</artifactId>
|
||||||
<version>6.10.3</version>
|
<version>2.3.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.seleniumhq.selenium</groupId>
|
|
||||||
<artifactId>selenium-java</artifactId>
|
|
||||||
<version>3.141.59</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -1,10 +1,6 @@
|
||||||
import io.cucumber.junit.Cucumber;
|
import cucumber.api.CucumberOptions;
|
||||||
import io.cucumber.junit.CucumberOptions;
|
import cucumber.api.junit.Cucumber;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
|
||||||
import stepdefs.Preconditions;
|
|
||||||
|
|
||||||
@RunWith(Cucumber.class)
|
@RunWith(Cucumber.class)
|
||||||
@CucumberOptions(
|
@CucumberOptions(
|
||||||
|
@ -13,13 +9,4 @@ import stepdefs.Preconditions;
|
||||||
)
|
)
|
||||||
|
|
||||||
public class RunTest {
|
public class RunTest {
|
||||||
@BeforeClass
|
|
||||||
public static void setup() {
|
|
||||||
Preconditions.driver= new FirefoxDriver();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void teardown() {
|
|
||||||
Preconditions.driver.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package stepdefs;
|
|
||||||
|
|
||||||
import org.openqa.selenium.WebDriver;
|
|
||||||
|
|
||||||
public class Preconditions {
|
|
||||||
public static WebDriver driver;
|
|
||||||
}
|
|
|
@ -1,68 +1,67 @@
|
||||||
package stepdefs;
|
package stepdefs;
|
||||||
|
|
||||||
import io.cucumber.java.PendingException;
|
import cucumber.api.java.en.Given;
|
||||||
import io.cucumber.java.en.Given;
|
import cucumber.api.java.en.Then;
|
||||||
import io.cucumber.java.en.Then;
|
import cucumber.api.java.en.When;
|
||||||
import io.cucumber.java.en.When;
|
|
||||||
|
|
||||||
public class PriceAlarm {
|
public class PriceAlarm {
|
||||||
@Given("^the user has at least (\\d+) price alarm set$")
|
@Given("^the user has at least (\\d+) price alarm set$")
|
||||||
public void the_user_has_at_least_price_alarm_set(int arg1) throws Exception {
|
public void the_user_has_at_least_price_alarm_set(int arg1) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user clicks on the profile icon$")
|
@When("^the user clicks on the profile icon$")
|
||||||
public void the_user_clicks_on_the_profile_icon() throws Exception {
|
public void the_user_clicks_on_the_profile_icon() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the profile details popup should open$")
|
@Then("^the profile details popup should open$")
|
||||||
public void the_profile_details_popup_should_open() throws Exception {
|
public void the_profile_details_popup_should_open() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user clicks on price alarms$")
|
@When("^the user clicks on price alarms$")
|
||||||
public void the_user_clicks_on_price_alarms() throws Exception {
|
public void the_user_clicks_on_price_alarms() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the price alarm list should open$")
|
@Then("^the price alarm list should open$")
|
||||||
public void the_price_alarm_list_should_open() throws Exception {
|
public void the_price_alarm_list_should_open() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the price alarm list should contain at least (\\d+) entry$")
|
@Then("^the price alarm list should contain at least (\\d+) entry$")
|
||||||
public void the_price_alarm_list_should_contain_at_least_entry(int arg1) throws Exception {
|
public void the_price_alarm_list_should_contain_at_least_entry(int arg1) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the price alarm list should contain a maximum of (\\d+) entries per page$")
|
@Then("^the price alarm list should contain a maximum of (\\d+) entries per page$")
|
||||||
public void the_price_alarm_list_should_contain_a_maximum_of_entries_per_page(int arg1) throws Exception {
|
public void the_price_alarm_list_should_contain_a_maximum_of_entries_per_page(int arg1) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Given("^the user is on the price alarm list page$")
|
@Given("^the user is on the price alarm list page$")
|
||||||
public void the_user_is_on_the_price_alarm_list_page() throws Exception {
|
public void the_user_is_on_the_price_alarm_list_page() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user clicks on the \"([^\"]*)\" button next to a price alarm$")
|
@When("^the user clicks on the \"([^\"]*)\" button next to a price alarm$")
|
||||||
public void the_user_clicks_on_the_button_next_to_a_price_alarm(String arg1) throws Exception {
|
public void the_user_clicks_on_the_button_next_to_a_price_alarm(String arg1) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^a popup should open asking the user to confirm the removal$")
|
@Then("^a popup should open asking the user to confirm the removal$")
|
||||||
public void a_popup_should_open_asking_the_user_to_confirm_the_removal() throws Exception {
|
public void a_popup_should_open_asking_the_user_to_confirm_the_removal() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user confirms the removal of the price alarm$")
|
@When("^the user confirms the removal of the price alarm$")
|
||||||
public void the_user_confirms_the_removal_of_the_price_alarm() throws Exception {
|
public void the_user_confirms_the_removal_of_the_price_alarm() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the price alarm should be removed from the database$")
|
@Then("^the price alarm should be removed from the database$")
|
||||||
public void the_price_alarm_should_be_removed_from_the_database() throws Exception {
|
public void the_price_alarm_should_be_removed_from_the_database() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^a popup should open where the user can edit the alarm$")
|
@Then("^a popup should open where the user can edit the alarm$")
|
||||||
public void a_popup_should_open_where_the_user_can_edit_the_alarm() throws Exception {
|
public void a_popup_should_open_where_the_user_can_edit_the_alarm() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user clicks on the \"([^\"]*)\" button$")
|
@When("^the user clicks on the \"([^\"]*)\" button$")
|
||||||
public void the_user_clicks_on_the_button(String arg1) throws Exception {
|
public void the_user_clicks_on_the_button(String arg1) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the price alarm should be updated in the database$")
|
@Then("^the price alarm should be updated in the database$")
|
||||||
public void the_price_alarm_should_be_updated_in_the_database() throws Exception {
|
public void the_price_alarm_should_be_updated_in_the_database() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +1,52 @@
|
||||||
package stepdefs;
|
package stepdefs;
|
||||||
|
|
||||||
import io.cucumber.java.PendingException;
|
import cucumber.api.PendingException;
|
||||||
import io.cucumber.java.en.Given;
|
import cucumber.api.java.en.Given;
|
||||||
import io.cucumber.java.en.Then;
|
import cucumber.api.java.en.Then;
|
||||||
import io.cucumber.java.en.When;
|
import cucumber.api.java.en.When;
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.Keys;
|
|
||||||
import org.openqa.selenium.WebElement;
|
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
||||||
|
|
||||||
public class SearchProduct {
|
public class SearchProduct {
|
||||||
@Given("^the user is on the landing page$")
|
@Given("^the user is on the landing page$")
|
||||||
public void the_user_is_on_the_landing_page() throws Exception {
|
public void the_user_is_on_the_landing_page() throws Exception {
|
||||||
//throw new PendingException();
|
}
|
||||||
Preconditions.driver.get("https://betterzon.xyz");
|
|
||||||
WebElement logo = (new WebDriverWait(Preconditions.driver, 10))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".logo")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@When("^the user enters the search term \"([^\"]*)\" and clicks search$")
|
@When("^the user enters the search term \"([^\"]*)\" and clicks search$")
|
||||||
public void the_user_enters_the_search_term_and_clicks_search(String searchTerm) throws Exception {
|
public void the_user_enters_the_search_term_and_clicks_search(String arg0) throws Exception {
|
||||||
WebElement searchField = Preconditions.driver.findElement(By.cssSelector(".ng-untouched.ng-pristine.ng-valid"));
|
}
|
||||||
searchField.sendKeys(searchTerm);
|
|
||||||
searchField.sendKeys(Keys.ENTER);
|
|
||||||
WebElement logo = (new WebDriverWait(Preconditions.driver, 10))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".logo")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Then("^the user should see the error page \"([^\"]*)\"$")
|
@Then("^the user should see the error page \"([^\"]*)\"$")
|
||||||
public void the_user_should_see_the_error_page(String arg0) throws Exception {
|
public void the_user_should_see_the_error_page(String arg0) throws Exception {
|
||||||
WebElement noProdsFoundMsg = (new WebDriverWait(Preconditions.driver, 10))
|
}
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".ng-star-inserted")));
|
|
||||||
assert(noProdsFoundMsg.getText().contains("No Products found!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Given("^the user is not logged in$")
|
@Given("^the user is not logged in$")
|
||||||
public void the_user_is_not_logged_in() throws Exception {
|
public void the_user_is_not_logged_in() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Given("^the user is logged in$")
|
@Given("^the user is logged in$")
|
||||||
public void the_user_is_logged_in() throws Exception {
|
public void the_user_is_logged_in() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the user should see a list of products$")
|
@Then("^the user should see a list of products$")
|
||||||
public void the_user_should_see_a_list_of_products() throws Exception {
|
public void the_user_should_see_a_list_of_products() throws Exception {
|
||||||
WebElement product = (new WebDriverWait(Preconditions.driver, 10))
|
}
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".productItem.ng-star-inserted")));
|
|
||||||
assert(product.isDisplayed());
|
|
||||||
}
|
|
||||||
|
|
||||||
@When("^the user clicks on the first product$")
|
@When("^the user clicks on the first product$")
|
||||||
public void the_user_clicks_on_the_first_product() throws Exception {
|
public void the_user_clicks_on_the_first_product() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the user should see the product detail page$")
|
@Then("^the user should see the product detail page$")
|
||||||
public void the_user_should_see_the_product_detail_page() throws Exception {
|
public void the_user_should_see_the_product_detail_page() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the set price alarm box should show \"([^\"]*)\"$")
|
@Then("^the set price alarm box should show \"([^\"]*)\"$")
|
||||||
public void the_set_price_alarm_box_should_show(String arg0) throws Exception {
|
public void the_set_price_alarm_box_should_show(String arg0) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user sets a price alarm$")
|
@When("^the user sets a price alarm$")
|
||||||
public void the_user_sets_a_price_alarm() throws Exception {
|
public void the_user_sets_a_price_alarm() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the user should receive an email confirming the price alarm$")
|
@Then("^the user should receive an email confirming the price alarm$")
|
||||||
public void the_user_should_receive_an_email_confirming_the_price_alarm() throws Exception {
|
public void the_user_should_receive_an_email_confirming_the_price_alarm() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
Feature: Price Alarms
|
Feature: Price Alarms
|
||||||
|
|
||||||
Scenario: Show a list of price alarms
|
Scenario: Show a list of price alarms
|
||||||
Given the user is on the landing page
|
Given the user is on the landing page
|
||||||
And the user is logged in
|
And the user is logged in
|
||||||
And the user has at least 1 price alarm set
|
And the user has at least 1 price alarm set
|
||||||
When the user clicks on the profile icon
|
When the user clicks on the profile icon
|
||||||
Then the profile details popup should open
|
Then the profile details popup should open
|
||||||
When the user clicks on price alarms
|
When the user clicks on price alarms
|
||||||
Then the price alarm list should open
|
Then the price alarm list should open
|
||||||
And the price alarm list should contain at least 1 entry
|
And the price alarm list should contain at least 1 entry
|
||||||
And the price alarm list should contain a maximum of 20 entries per page
|
And the price alarm list should contain a maximum of 20 entries per page
|
||||||
|
|
||||||
Scenario: Remove a price alarm
|
Scenario: Remove a price alarm
|
||||||
Given the user is on the price alarm list page
|
Given the user is on the price alarm list page
|
||||||
And the user is logged in
|
And the user is logged in
|
||||||
When the user clicks on the "remove" button next to a price alarm
|
When the user clicks on the "remove" button next to a price alarm
|
||||||
Then a popup should open asking the user to confirm the removal
|
Then a popup should open asking the user to confirm the removal
|
||||||
When the user confirms the removal of the price alarm
|
When the user confirms the removal of the price alarm
|
||||||
Then the price alarm should be removed from the database
|
Then the price alarm should be removed from the database
|
||||||
|
|
||||||
Scenario: Edit a price alarm
|
Scenario: Edit a price alarm
|
||||||
Given the user is on the price alarm list page
|
Given the user is on the price alarm list page
|
||||||
And the user is logged in
|
And the user is logged in
|
||||||
When the user clicks on the "edit" button next to a price alarm
|
When the user clicks on the "edit" button next to a price alarm
|
||||||
Then a popup should open where the user can edit the alarm
|
Then a popup should open where the user can edit the alarm
|
||||||
When the user clicks on the "save changes" button
|
When the user clicks on the "save changes" button
|
||||||
Then the price alarm should be updated in the database
|
Then the price alarm should be updated in the database
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
Feature: Search a Product
|
Feature: Search a Product
|
||||||
|
|
||||||
Scenario: User searches for unknown product
|
Scenario: User searches for unknown product
|
||||||
Given the user is on the landing page
|
Given the user is on the landing page
|
||||||
When the user enters the search term "iPhone 13" and clicks search
|
When the user enters the search term "iPhone 13" and clicks search
|
||||||
Then the user should see the error page "No products found"
|
Then the user should see the error page "No products found"
|
||||||
|
|
||||||
Scenario: User is not logged in, searches for known product
|
Scenario: User is not logged in, searches for known product
|
||||||
Given the user is on the landing page
|
Given the user is on the landing page
|
||||||
And the user is not logged in
|
And the user is not logged in
|
||||||
When the user enters the search term "iPhone 12" and clicks search
|
When the user enters the search term "iPhone 12" and clicks search
|
||||||
Then the user should see a list of products
|
Then the user should see a list of products
|
||||||
When the user clicks on the first product
|
When the user clicks on the first product
|
||||||
Then the user should see the product detail page
|
Then the user should see the product detail page
|
||||||
And the set price alarm box should show "Log in to continue"
|
And the set price alarm box should show "Log in to continue"
|
||||||
|
|
||||||
Scenario: User is logged in, searches for known product
|
Scenario: User is logged in, searches for known product
|
||||||
Given the user is on the landing page
|
Given the user is on the landing page
|
||||||
And the user is logged in
|
And the user is logged in
|
||||||
When the user enters the search term "iPhone 12" and clicks search
|
When the user enters the search term "iPhone 12" and clicks search
|
||||||
Then the user should see a list of products
|
Then the user should see a list of products
|
||||||
When the user clicks on the first product
|
When the user clicks on the first product
|
||||||
Then the user should see the product detail page
|
Then the user should see the product detail page
|
||||||
And the set price alarm box should show "Set price alarm"
|
And the set price alarm box should show "Set price alarm"
|
||||||
When the user sets a price alarm
|
When the user sets a price alarm
|
||||||
Then the user should receive an email confirming the price alarm
|
Then the user should receive an email confirming the price alarm
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {FooterComponent} from './footer.component';
|
import {FooterComponent} from './footer.component';
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
import {AppComponent} from '../../app.component';
|
import {AppComponent} from "../../app.component";
|
||||||
import {ImprintComponent} from '../../pages/imprint/imprint.component';
|
import {ImprintComponent} from "../../pages/imprint/imprint.component";
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
|
|
||||||
describe('FooterComponent', () => {
|
describe('FooterComponent', () => {
|
||||||
let component: FooterComponent;
|
let component: FooterComponent;
|
||||||
let fixture: ComponentFixture<FooterComponent>;
|
let fixture: ComponentFixture<FooterComponent>;
|
||||||
const router = {
|
let router = {
|
||||||
navigate: jasmine.createSpy('navigate'),
|
navigate: jasmine.createSpy('navigate'),
|
||||||
routerState: jasmine.createSpy('routerState')
|
routerState: jasmine.createSpy('routerState')
|
||||||
};
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {HeaderComponent} from './header.component';
|
import {HeaderComponent} from './header.component';
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
import {MatMenuModule} from '@angular/material/menu';
|
import {MatMenuModule} from "@angular/material/menu";
|
||||||
import {Router} from '@angular/router';
|
import {Router} from "@angular/router";
|
||||||
|
|
||||||
describe('HeaderComponent', () => {
|
describe('HeaderComponent', () => {
|
||||||
let component: HeaderComponent;
|
let component: HeaderComponent;
|
||||||
let fixture: ComponentFixture<HeaderComponent>;
|
let fixture: ComponentFixture<HeaderComponent>;
|
||||||
const router = {
|
let router = {
|
||||||
navigate: jasmine.createSpy('navigate'),
|
navigate: jasmine.createSpy('navigate'),
|
||||||
navigateByUrl: (url: string) => {
|
navigateByUrl: (url: string) => {
|
||||||
return {
|
return {
|
||||||
then: () => {
|
then: () => {}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {NewestPricesListComponent} from './newest-prices-list.component';
|
import {NewestPricesListComponent} from './newest-prices-list.component';
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
import {HttpClient} from '@angular/common/http';
|
import {HttpClient} from "@angular/common/http";
|
||||||
import {AbstractMockObservableService} from '../../mocks/mock.service';
|
import {AbstractMockObservableService} from "../../mocks/mock.service";
|
||||||
import {ApiService} from '../../services/api.service';
|
import {ApiService} from "../../services/api.service";
|
||||||
import {Observable} from 'rxjs';
|
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
class MockApiService extends AbstractMockObservableService {
|
||||||
getCurrentPricePerVendor(): any {
|
getCurrentPricePerVendor() {
|
||||||
this.content = [];
|
this.content = [];
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getVendors(): any {
|
getVendors() {
|
||||||
const vendor = {
|
const vendor = {
|
||||||
vendor_id: 1,
|
vendor_id: 1,
|
||||||
name: 'Max Mustermann',
|
name: 'Max Mustermann',
|
||||||
|
|
|
@ -1,33 +1,18 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {ProductDetailsComponent} from './product-details.component';
|
import {ProductDetailsComponent} from './product-details.component';
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
import {AbstractMockObservableService} from '../../mocks/mock.service';
|
import {AbstractMockObservableService} from "../../mocks/mock.service";
|
||||||
import {ApiService} from '../../services/api.service';
|
import {ApiService} from "../../services/api.service";
|
||||||
import {ChartComponent, NgApexchartsModule} from 'ng-apexcharts';
|
import {ChartComponent, NgApexchartsModule} from "ng-apexcharts";
|
||||||
import {By} from '@angular/platform-browser';
|
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
class MockApiService extends AbstractMockObservableService {
|
||||||
getProduct(): any {
|
getProduct() {
|
||||||
const product = {
|
this.content = {};
|
||||||
product_id: 1,
|
|
||||||
asin: 'ASIN',
|
|
||||||
is_active: true,
|
|
||||||
name: 'Super tolles Produkt',
|
|
||||||
short_description: 'Descr',
|
|
||||||
long_description: 'Descr',
|
|
||||||
image_guid: '123',
|
|
||||||
date_added: new Date(),
|
|
||||||
last_modified: new Date(),
|
|
||||||
manufacturer_id: 1,
|
|
||||||
selling_rank: '1',
|
|
||||||
category_id: 1
|
|
||||||
};
|
|
||||||
this.content = product;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getLowestPrices(): any {
|
getLowestPrices() {
|
||||||
const price = {
|
const price = {
|
||||||
price_id: 1,
|
price_id: 1,
|
||||||
product_id: 1,
|
product_id: 1,
|
||||||
|
@ -39,12 +24,12 @@ class MockApiService extends AbstractMockObservableService {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAmazonPrice(): any {
|
getAmazonPrice() {
|
||||||
this.content = {};
|
this.content = {};
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getVendors(): any {
|
getVendors() {
|
||||||
const vendor = {
|
const vendor = {
|
||||||
vendor_id: 1,
|
vendor_id: 1,
|
||||||
name: 'Max Mustermann',
|
name: 'Max Mustermann',
|
||||||
|
@ -54,7 +39,7 @@ class MockApiService extends AbstractMockObservableService {
|
||||||
country_code: 'DE',
|
country_code: 'DE',
|
||||||
phone: '+49 123 4567890',
|
phone: '+49 123 4567890',
|
||||||
website: 'https://www.amazon.de',
|
website: 'https://www.amazon.de',
|
||||||
};
|
}
|
||||||
this.content = [vendor];
|
this.content = [vendor];
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -87,10 +72,4 @@ describe('ProductDetailsComponent', () => {
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the product name', () => {
|
|
||||||
component.ngOnInit();
|
|
||||||
const title = fixture.debugElement.query(By.css('.productTitle'));
|
|
||||||
expect(title.nativeElement.innerText).toEqual('Super tolles Produkt');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {ProductListComponent} from './product-list.component';
|
import {ProductListComponent} from './product-list.component';
|
||||||
import {FooterComponent} from '../footer/footer.component';
|
import {FooterComponent} from "../footer/footer.component";
|
||||||
import {HeaderComponent} from '../header/header.component';
|
import {HeaderComponent} from "../header/header.component";
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
import {ApiService} from '../../services/api.service';
|
import {ApiService} from "../../services/api.service";
|
||||||
import {AbstractMockObservableService} from '../../mocks/mock.service';
|
import {AbstractMockObservableService} from "../../mocks/mock.service";
|
||||||
import {Router} from '@angular/router';
|
import {Router} from "@angular/router";
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
class MockApiService extends AbstractMockObservableService {
|
||||||
getProducts(): any {
|
getProducts() {
|
||||||
this.content = [];
|
this.content = [];
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getProductsByQuery(): any {
|
getProductsByQuery() {
|
||||||
this.content = [];
|
this.content = [];
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ describe('ProductListComponent', () => {
|
||||||
let component: ProductListComponent;
|
let component: ProductListComponent;
|
||||||
let fixture: ComponentFixture<ProductListComponent>;
|
let fixture: ComponentFixture<ProductListComponent>;
|
||||||
let mockService;
|
let mockService;
|
||||||
const router = {
|
let router = {
|
||||||
navigate: jasmine.createSpy('navigate'),
|
navigate: jasmine.createSpy('navigate'),
|
||||||
routerState: jasmine.createSpy('routerState')
|
routerState: jasmine.createSpy('routerState')
|
||||||
};
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockService = new MockApiService();
|
mockService = new MockApiService();
|
||||||
|
@ -71,7 +71,7 @@ describe('ProductListComponent', () => {
|
||||||
manufacturer_id: 1,
|
manufacturer_id: 1,
|
||||||
selling_rank: '1',
|
selling_rank: '1',
|
||||||
category_id: 1
|
category_id: 1
|
||||||
};
|
}
|
||||||
|
|
||||||
component.clickedProduct(product);
|
component.clickedProduct(product);
|
||||||
expect(router.navigate).toHaveBeenCalledWith(['/product/1']);
|
expect(router.navigate).toHaveBeenCalledWith(['/product/1']);
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {LandingpageComponent} from './landingpage.component';
|
import {LandingpageComponent} from './landingpage.component';
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
import {Router} from '@angular/router';
|
import {Router} from "@angular/router";
|
||||||
|
|
||||||
describe('LandingpageComponent', () => {
|
describe('LandingpageComponent', () => {
|
||||||
let component: LandingpageComponent;
|
let component: LandingpageComponent;
|
||||||
let fixture: ComponentFixture<LandingpageComponent>;
|
let fixture: ComponentFixture<LandingpageComponent>;
|
||||||
const router = {
|
let router = {
|
||||||
navigate: jasmine.createSpy('navigate'),
|
navigate: jasmine.createSpy('navigate'),
|
||||||
routerState: jasmine.createSpy('routerState')
|
routerState: jasmine.createSpy('routerState')
|
||||||
};
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {ProductDetailPageComponent} from './product-detail-page.component';
|
import {ProductDetailPageComponent} from './product-detail-page.component';
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
|
|
||||||
describe('ProductDetailPageComponent', () => {
|
describe('ProductDetailPageComponent', () => {
|
||||||
let component: ProductDetailPageComponent;
|
let component: ProductDetailPageComponent;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import {ProductSearchPageComponent} from './product-search-page.component';
|
import {ProductSearchPageComponent} from './product-search-page.component';
|
||||||
import {HeaderComponent} from '../../components/header/header.component';
|
import {HeaderComponent} from "../../components/header/header.component";
|
||||||
import {FooterComponent} from '../../components/footer/footer.component';
|
import {FooterComponent} from "../../components/footer/footer.component";
|
||||||
import {ProductListComponent} from '../../components/product-list/product-list.component';
|
import {ProductListComponent} from "../../components/product-list/product-list.component";
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
|
|
||||||
describe('ProductSearchPageComponent', () => {
|
describe('ProductSearchPageComponent', () => {
|
||||||
let component: ProductSearchPageComponent;
|
let component: ProductSearchPageComponent;
|
||||||
|
|
|
@ -3,9 +3,9 @@ Website: https://www.betterzon.xyz<br>
|
||||||
Blog: https://blog.betterzon.xyz<br>
|
Blog: https://blog.betterzon.xyz<br>
|
||||||
Wiki: https://github.com/Mueller-Patrick/Betterzon/wiki
|
Wiki: https://github.com/Mueller-Patrick/Betterzon/wiki
|
||||||
|
|
||||||
# Code Quality
|
|
||||||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/88e47ebf837b43af9d12147c22f77f7f)](https://www.codacy.com/gh/Mueller-Patrick/Betterzon/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Mueller-Patrick/Betterzon&utm_campaign=Badge_Grade)
|
|
||||||
|
|
||||||
# Project Status
|
# Project Status
|
||||||
|
![Latest Commit Build Status](https://ci.betterzon.xyz/job/Verify_Build_on_PR/badge/icon?style=flat-square&subject=Latest%20Commit)
|
||||||
|
![Deployment Status](https://ci.betterzon.xyz/job/GitHub%20Deployment/badge/icon?style=flat-square&subject=Deployment&status=Success)
|
||||||
|
<br>
|
||||||
[![Website Status](https://img.shields.io/website?label=www.betterzon.xyz&style=for-the-badge&url=https%3A%2F%2Fwww.betterzon.xyz)](https://www.betterzon.xyz)
|
[![Website Status](https://img.shields.io/website?label=www.betterzon.xyz&style=for-the-badge&url=https%3A%2F%2Fwww.betterzon.xyz)](https://www.betterzon.xyz)
|
||||||
[![Blog Status](https://img.shields.io/website?label=blog.betterzon.xyz&style=for-the-badge&url=https%3A%2F%2Fblog.betterzon.xyz)](https://blog.betterzon.xyz)
|
[![Blog Status](https://img.shields.io/website?label=blog.betterzon.xyz&style=for-the-badge&url=https%3A%2F%2Fblog.betterzon.xyz)](https://blog.betterzon.xyz)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user