Skip to content

Commit

Permalink
feat: add user info api
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Feb 5, 2024
1 parent 7efc083 commit b0a77ab
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
17 changes: 17 additions & 0 deletions packages/canyon-backend/src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Controller, Get, UseGuards, Request } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';

@Controller()
export class UserController {
constructor(private readonly prismaService: PrismaService) {}
@UseGuards(JwtAuthGuard)
@Get('/api/user')
getHello(@Request() req): Promise<any> {
return this.prismaService.user.findFirst({
where: {
id: req.user.id,
},
});
}
}
4 changes: 3 additions & 1 deletion packages/canyon-backend/src/user/user.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Module } from '@nestjs/common';
import { UserResolver } from './user.resolver';
import { UserService } from './user.service';
import { PrismaModule } from 'src/prisma/prisma.module'
import { PrismaModule } from 'src/prisma/prisma.module';
import { UserController } from './user.controller';

@Module({
imports: [PrismaModule],
controllers: [UserController],
providers: [UserResolver, UserService],
exports: [UserService],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const IstanbulReport: FC<IstanbulReportProps> = ({
/>
)
)}
{loading && <div className="loading">loading...</div>}
</div>
);
};
Expand Down
16 changes: 9 additions & 7 deletions packages/canyon-report/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ function getDecode(str: string) {
const report = init(document.querySelector('#root') as any, {
onSelectFile(path: string) {
return new Promise((resolve) => {
resolve({
// @ts-ignore
fileCoverage: __coverage__[path],
// @ts-ignore
fileContent: getDecode(__filecontent__[path]),
fileCodeChange:[1,2,3,4]
});
setTimeout(()=>{
resolve({
// @ts-ignore
fileCoverage: __coverage__[path],
// @ts-ignore
fileContent: getDecode(__filecontent__[path]),
fileCodeChange:[1,2,3,4]
});
},1000)
});
},
});
Expand Down

0 comments on commit b0a77ab

Please sign in to comment.