Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"generate:schema": "ts-node generate-typings.ts && cp src/graphql.schema.ts src/graphql.ts"
},
"dependencies": {
"@helixbridge/helixconf": "1.2.0-beta",
"@helixbridge/helixconf": "1.2.0",
"@nestjs/apollo": "^10.0.9",
"@nestjs/common": "^8.4.6",
"@nestjs/config": "^2.1.0",
Expand Down
24 changes: 23 additions & 1 deletion apollo/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, Query, Param } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
Expand All @@ -9,4 +9,26 @@ export class AppController {
getHello(): string {
return this.appService.getHello();
}

@Get('quest/used')
async questUsedHelix(@Query('address') address: string) {
return await this.appService.questUsedHelix(
{
sender: address.toLowerCase(),
},
1
);
}

@Get('quest/after/:timestamp/times/:times')
async questUsedAfterAnd3Times(
@Param('timestamp') timestamp: string,
@Param('times') times: string,
@Query('address') address: string) {
const where = {
sender: address.toLowerCase(),
startTime: { gt: Number(timestamp) },
};
return await this.appService.questUsedHelix(where, Number(times));
}
}
26 changes: 25 additions & 1 deletion apollo/src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
import { Injectable } from '@nestjs/common';
import { Prisma, PrismaClient } from '@prisma/client';

@Injectable()
export class AppService {
export class AppService extends PrismaClient {
getHello(): string {
return 'Hello World!';
}

async questUsedHelix(where: Prisma.HistoryRecordWhereInput, times: number) {
const total = await this.historyRecord.count({
where,
});
if (total >= times) {
return {
data: {
result: true,
},
};
} else {
return {
error: {
code: 0,
message: `user sent count ${total}`,
},
data: {
result: false,
},
};
}
}
}
8 changes: 4 additions & 4 deletions apollo/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,10 @@
dependencies:
tslib "^2.4.0"

"@helixbridge/[email protected]-beta":
version "1.2.0-beta"
resolved "https://registry.yarnpkg.com/@helixbridge/helixconf/-/helixconf-1.2.0-beta.tgz#4f46ac1c33af3717710ac3ffe7f036f6ddf244e9"
integrity sha512-YuFOhX33quFUwOvduSzo01ul7SWus2OicDTulJLbPdg000Qs37s0WJ80n1fK8FSDgvBMToC8oaxnimwTl6fT9Q==
"@helixbridge/[email protected]":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@helixbridge/helixconf/-/helixconf-1.2.0.tgz#56fa247ed3286303ae6f8efa65932d5df901595a"
integrity sha512-vZwelfwuDluCKP19xHqatMEPZmCnKpkvWWJBdRTClYYFCva79qpjzKM7SxOcFhOqygbobwFRgNVV4JLDJVg8Qg==

"@istanbuljs/load-nyc-config@^1.0.0":
version "1.1.0"
Expand Down
Loading