-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support npm search command like npmio
- Loading branch information
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// TODO sync event | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { EggAppConfig } from 'egg'; | ||
import { Event, Inject } from '@eggjs/tegg'; | ||
import { | ||
PACKAGE_UNPUBLISHED, | ||
PACKAGE_VERSION_ADDED, | ||
PACKAGE_VERSION_REMOVED, | ||
PACKAGE_TAG_ADDED, | ||
PACKAGE_TAG_CHANGED, | ||
PACKAGE_TAG_REMOVED, | ||
PACKAGE_MAINTAINER_CHANGED, | ||
PACKAGE_MAINTAINER_REMOVED, | ||
PACKAGE_META_CHANGED, PackageMetaChange, | ||
} from './index'; | ||
|
||
import { PackageSearchService } from '../service/PackageSearchService'; | ||
import { User } from '../entity/User'; | ||
|
||
class SyncESPackage { | ||
@Inject() | ||
protected readonly packageSearchService: PackageSearchService; | ||
|
||
@Inject() | ||
protected readonly config: EggAppConfig; | ||
|
||
protected async doSomething(): Promise<unknown> { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_UNPUBLISHED) | ||
export class PackageUnpublished extends SyncESPackage { | ||
async handle() { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_VERSION_ADDED) | ||
export class PackageVersionAdded extends SyncESPackage { | ||
async handle(_fullname: string, _version: string, _tag?: string) { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_VERSION_REMOVED) | ||
export class PackageVersionRemoved extends SyncESPackage { | ||
async handle(_fullname: string, _version: string, _tag?: string) { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_TAG_ADDED) | ||
export class PackageTagAdded extends SyncESPackage { | ||
async handle(_fullname: string, _tag: string) { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_TAG_CHANGED) | ||
export class PackageTagChanged extends SyncESPackage { | ||
async handle(_fullname: string, _tag: string) { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_TAG_REMOVED) | ||
export class PackageTagRemoved extends SyncESPackage { | ||
async handle(_fullname: string, _tag: string) { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_MAINTAINER_CHANGED) | ||
export class PackageMaintainerChanged extends SyncESPackage { | ||
async handle(_fullname: string, _maintainers: User[]) { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_MAINTAINER_REMOVED) | ||
export class PackageMaintainerRemoved extends SyncESPackage { | ||
async handle(_fullname: string, _maintainer: string) { | ||
throw Error('Not Implemented'); | ||
} | ||
} | ||
|
||
@Event(PACKAGE_META_CHANGED) | ||
export class PackageMetaChanged extends SyncESPackage { | ||
async handle(_fullname: string, _meta: PackageMetaChange) { | ||
throw Error('Not Implemented'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AccessLevel, SingletonProto } from '@eggjs/tegg'; | ||
import { AbstractService } from '../../common/AbstractService'; | ||
|
||
@SingletonProto({ | ||
accessLevel: AccessLevel.PUBLIC, | ||
}) | ||
export class PackageSearchService extends AbstractService { | ||
createOrUpdatePackage() { | ||
throw Error('Not Implemented'); | ||
} | ||
|
||
searchPackage() { | ||
throw Error('Not Implemented'); | ||
} | ||
|
||
removePackage() { | ||
throw Error('Not Implemented'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
HTTPController, | ||
HTTPMethod, | ||
HTTPMethodEnum, | ||
Context, | ||
EggContext, | ||
HTTPQuery, | ||
Inject, | ||
} from '@eggjs/tegg'; | ||
import { AbstractController } from '../AbstractController'; | ||
import { Client as ElasticsearchClient } from '@elastic/elasticsearch'; | ||
|
||
@HTTPController() | ||
export class SearchPackageController extends AbstractController { | ||
@Inject() | ||
private readonly elasticsearch: ElasticsearchClient; | ||
@HTTPMethod({ | ||
// GET /-/v1/search?text=react&size=20&from=0&quality=0.65&popularity=0.98&maintenance=0.5 | ||
path: '/-/v1/search', | ||
method: HTTPMethodEnum.GET, | ||
}) | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
async search(@Context() _ctx: EggContext, @HTTPQuery() _text: string) { | ||
console.log(this.elasticsearch); | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters