File tree 8 files changed +117
-14
lines changed
8 files changed +117
-14
lines changed Original file line number Diff line number Diff line change 2
2
node_modules
3
3
4
4
# Nuxt dev/build outputs
5
+ .turbo
5
6
.output
6
7
.data
7
8
.nuxt
Original file line number Diff line number Diff line change 1
1
{
2
- "name" : " get-bonus" ,
2
+ "name" : " @ get-bonus/monorepo " ,
3
3
"private" : true ,
4
4
"type" : " module" ,
5
5
"scripts" : {
6
- "build" : " nuxt build" ,
6
+ "build" : " turbo run build && nuxt build" ,
7
7
"dev" : " nuxt dev" ,
8
8
"generate" : " nuxt generate" ,
9
9
"postinstall" : " nuxt prepare" ,
Original file line number Diff line number Diff line change 36
36
},
37
37
"engines" : {
38
38
"node" : " >=v20.10.0"
39
+ },
40
+ "dependencies" : {
41
+ "cheerio" : " 1.0.0-rc.12"
39
42
}
40
43
}
Original file line number Diff line number Diff line change 1
- export function hello ( ) {
2
- return 'world' ;
3
- }
1
+ export * from './scraper' ;
2
+
3
+ export * from './melonbooks' ;
Original file line number Diff line number Diff line change
1
+ import type { Detail , SearchResult } from '../types' ;
2
+
3
+ import { Provider } from '../scraper' ;
4
+
5
+ export class Melonbooks extends Provider {
6
+ constructor ( ) {
7
+ super ( 'melonbooks' ) ;
8
+ }
9
+
10
+ search ( text : string ) : Promise < SearchResult [ ] > {
11
+ throw new Error ( 'Method not implemented.' ) ;
12
+ }
13
+
14
+ detail ( url : string ) : Promise < Detail > {
15
+ throw new Error ( 'Method not implemented.' ) ;
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ import type { SearchResult , Detail } from './types' ;
2
+
3
+ export class Scraper {
4
+ private readonly providers : Provider [ ] ;
5
+
6
+ public constructor ( ...providers : Provider [ ] ) {
7
+ this . providers = providers ;
8
+ }
9
+
10
+ async search ( text : string ) {
11
+ const results = await Promise . all (
12
+ this . providers . map ( async ( provider ) => {
13
+ const resp = await provider . search ( text ) ;
14
+ return resp ;
15
+ } )
16
+ ) ;
17
+ return results ;
18
+ }
19
+
20
+ async getDetail ( platform : string , url : string ) {
21
+ const providers = this . providers . filter ( ( p ) => p . platform === platform ) ;
22
+ }
23
+
24
+ async getAllDetails ( search : SearchResult [ ] ) { }
25
+ }
26
+
27
+ export abstract class Provider {
28
+ public readonly platform : string ;
29
+
30
+ constructor ( name : string ) {
31
+ this . platform = name ;
32
+ }
33
+
34
+ abstract search ( text : string ) : Promise < SearchResult [ ] > ;
35
+
36
+ abstract detail ( url : string ) : Promise < Detail > ;
37
+ }
Original file line number Diff line number Diff line change
1
+ export interface SearchResult { }
2
+
3
+ export interface Detail { }
You can’t perform that action at this time.
0 commit comments