This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa4bef9
commit dc249d5
Showing
17 changed files
with
235 additions
and
177 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,75 @@ | ||
mutation CreateOpenSource { | ||
createOpenSource( | ||
input: { | ||
title: "test4" | ||
description: "1test2" | ||
url: "https://t4est3.com" | ||
posterUrl: "https://1test4.com" | ||
} | ||
) { | ||
_id | ||
title | ||
description | ||
url | ||
posterUrl | ||
createdAt | ||
updatedAt | ||
} | ||
} | ||
|
||
query GetOpenSources{ | ||
getOpenSources { | ||
_id | ||
title | ||
description | ||
url | ||
posterUrl | ||
createdAt | ||
updatedAt | ||
} | ||
} | ||
|
||
mutation UpdateOpenSourceById { | ||
updateOpenSourceById( | ||
input: { | ||
id: "f4b445d6-d569-4a29-a760-da497675db38" | ||
title: "test2" | ||
description: "test2" | ||
url: "https://test2.com" | ||
posterUrl: "https://test2.com" | ||
} | ||
) { | ||
_id | ||
title | ||
description | ||
url | ||
posterUrl | ||
createdAt | ||
updatedAt | ||
} | ||
} | ||
|
||
mutation DeleteOpenSourceById { | ||
deleteOpenSourceById(id: "f4b445d6-d569-4a29-a760-da497675db38") { | ||
_id | ||
title | ||
description | ||
url | ||
posterUrl | ||
createdAt | ||
updatedAt | ||
} | ||
} | ||
|
||
mutation DeleteOpenSources { | ||
deleteOpenSources( | ||
ids: [ | ||
"60e5c5a2-f69f-41df-bc04-53f9c699e498" | ||
"00c602bd-e364-491d-abb1-45cf930ac443" | ||
] | ||
) { | ||
n | ||
ok | ||
deletedCount | ||
} | ||
} |
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,20 @@ | ||
mutation SendSMS { | ||
sendSMS( | ||
input: { | ||
phoneNumber: "150111896x39" | ||
} | ||
) { | ||
verificationCode | ||
} | ||
} | ||
|
||
mutation ValidateSMS { | ||
validateSMS( | ||
input: { | ||
phoneNumber: "15011189639x", | ||
verificationCode:"3213" | ||
} | ||
) { | ||
success | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import { Module } from '@nestjs/common' | ||
import { Module, HttpModule } from '@nestjs/common' | ||
import { BandwagonService } from './bandwagon.service' | ||
import { BandwagonResolver } from './bandwagon.resolver' | ||
|
||
@Module({ | ||
imports: [ | ||
HttpModule.registerAsync({ | ||
useFactory: () => ({ | ||
timeout: 5000, | ||
maxRedirects: 5, | ||
}), | ||
}), | ||
], | ||
providers: [BandwagonService, BandwagonResolver], | ||
}) | ||
export class BandwagonModule {} |
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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
// import { UseGuards } from '@nestjs/common' | ||
import { Resolver, Query } from '@nestjs/graphql' | ||
import { BandwagonService } from './bandwagon.service' | ||
import { ServerInfoModel } from './models/server-info.model' | ||
import { ServiceInfoModel } from './models/service-info.model' | ||
import { UsageStatesModel } from './models/usage-stats.model' | ||
// import { GqlAuthGuard } from '../guard/gqlAuth.guard' | ||
|
||
@Resolver(() => ServerInfoModel) | ||
@Resolver('Bandwagon') | ||
export class BandwagonResolver { | ||
constructor(private readonly bandwagonService: BandwagonService) { | ||
this.bandwagonService = bandwagonService | ||
} | ||
|
||
@Query(() => ServerInfoModel) | ||
public async getServiceInfo() { | ||
@Query(() => ServiceInfoModel) | ||
// @UseGuards(GqlAuthGuard) | ||
public getBanwagonServiceInfo() { | ||
return this.bandwagonService.getServiceInfo() | ||
} | ||
|
||
@Query(() => [ServerInfoModel]) | ||
public async getUsageStats() { | ||
@Query(() => [UsageStatesModel]) | ||
// @UseGuards(GqlAuthGuard) | ||
public getBanwagonUsageStats() { | ||
return this.bandwagonService.getUsageStats() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,34 @@ | ||
import { Injectable } from '@nestjs/common' | ||
import { ServerInfoModel } from './models/server-info.model' | ||
import { Injectable, HttpService } from '@nestjs/common' | ||
import { Observable } from 'rxjs' | ||
import { map } from 'rxjs/operators' | ||
import { AxiosResponse } from 'axios' | ||
import { BandwagonParams } from './interfaces/bandwagon-params.interface' | ||
import { ServiceInfo } from './interfaces/service-info.interface' | ||
import { UsageStats } from './interfaces/usage-stats.interface' | ||
import { ConfigService } from '../config/config.service' | ||
import { BANDWAGON_SERVICE_INFO_URL, BANDWAGON_USAGE_STATS_URL } from '../shared/constants' | ||
|
||
@Injectable() | ||
export class BandwagonService { | ||
public async getServiceInfo(): Promise<ServerInfoModel[]> { | ||
return {} as ServerInfoModel[] | ||
private readonly params: BandwagonParams | ||
|
||
constructor(private readonly httpService: HttpService, configService: ConfigService) { | ||
this.httpService = httpService | ||
|
||
const { BANDWAGON_SECRET_KEY, BANDWAGON_SERVER_ID } = configService.getBandwagonKeys() | ||
|
||
this.params = { veid: BANDWAGON_SERVER_ID, api_key: BANDWAGON_SECRET_KEY } | ||
} | ||
|
||
public getServiceInfo(): Observable<AxiosResponse<ServiceInfo>> { | ||
return this.httpService | ||
.get(BANDWAGON_SERVICE_INFO_URL, { params: this.params }) | ||
.pipe(map(response => response.data)) | ||
} | ||
|
||
public async getUsageStats(): Promise<ServerInfoModel[]> { | ||
return {} as ServerInfoModel[] | ||
public getUsageStats(): Observable<AxiosResponse<UsageStats>> { | ||
return this.httpService | ||
.get(BANDWAGON_USAGE_STATS_URL, { params: this.params }) | ||
.pipe(map(response => response.data.data)) | ||
} | ||
} |
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,4 @@ | ||
export interface BandwagonParams { | ||
veid: string | ||
api_key: string | ||
} |
2 changes: 1 addition & 1 deletion
2
...wagon/interfaces/server-info.interface.ts → ...agon/interfaces/service-info.interface.ts
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface ServerInfo { | ||
export interface ServiceInfo { | ||
vm_type: string | ||
ve_status: string | ||
ve_mac1: string | ||
|
Oops, something went wrong.