Skip to content

Commit

Permalink
added product theme support
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukhu committed Mar 19, 2019
1 parent d4285b2 commit dc5061c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
12 changes: 7 additions & 5 deletions server/api/controllers/scraper/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ScraperController implements interfaces.Controller {
this.loggerService.logAPITrace(req, res, HttpStatus.OK);
this.metricsService.logAPIMetrics(req, res, HttpStatus.OK);
if (save) {
this.scraperService.push(name, data);
this.scraperService.push(name, data, '{}');
}
resolve({ data: { name, data }, status: HttpStatus.OK });
}
Expand All @@ -137,7 +137,10 @@ class ScraperController implements interfaces.Controller {
}

@httpGet('/publish')
public async getPublishedSite(@request() req: Request, @response() res: Response) {
public async getPublishedSite(
@request() req: Request,
@response() res: Response
) {
const result: APIResponse = await new Promise((resolve, reject) => {
this.scraperService.getAllSites().subscribe(
r => {
Expand Down Expand Up @@ -264,9 +267,9 @@ class ScraperController implements interfaces.Controller {
@httpPost('/products')
public async push(@request() req: Request, @response() res: Response) {
const result: APIResponse = await new Promise((resolve, reject) => {
const { name, data } = req.body;
const { name, data, theme } = req.body;
this.loggerService.info(name);
this.scraperService.push(name, data).subscribe(
this.scraperService.push(name, data, theme).subscribe(
r => {
if (r === undefined) {
this.loggerService.logAPITrace(
Expand Down Expand Up @@ -335,7 +338,6 @@ class ScraperController implements interfaces.Controller {
});
}


@httpGet('/products/:name')
public async byMicrositeByName(
@requestParam('name') name: string,
Expand Down
2 changes: 1 addition & 1 deletion server/api/interfaces/iscraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface IScraper {

getScrapedListData(asinList: string): Observable<any>;

push(name: string, data: string): Observable<any>;
push(name: string, data: string, theme: string): Observable<any>;
pushSite(name: string, data: string): Observable<any>;

byMicrositeByID(name: string): Observable<any>;
Expand Down
4 changes: 2 additions & 2 deletions server/api/services/scraper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ class ScraperService implements IScraper {
);
};

public push(name: string, data: string): Observable<any> {
public push(name: string, data: string, theme: string): Observable<any> {
this.initDb();
return from(
new Promise((resolve, reject) => {
try {
this.loggerService.info(name);
this.db.push(`/${name}`, data);
this.db.push(`/${name}`, { data, theme });
resolve(data);
} catch (error) {
// The error will tell you where the DataPath stopped. In this case test1
Expand Down
15 changes: 15 additions & 0 deletions server/common/swagger/Api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ definitions:
type: array
items:
$ref: '#/definitions/product'
theme:
type: object
title: Page Theme
properties:
page:
type: object
title: page theme
properties:
backgroundImage:
type: string
description: background Image
background:
type: string
description: background color

product:
type: object
title: scraped product
Expand Down

0 comments on commit dc5061c

Please sign in to comment.