updating terraform

This commit is contained in:
2025-02-23 14:03:21 -06:00
parent fd5dcf5756
commit 335556e7fe
18 changed files with 195 additions and 399 deletions

View File

@@ -28,7 +28,7 @@
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@noahspan/azure-database": "^3.1.2",
"@noahspan/noahspan-modules": "^0.5.2",
"@noahspan/noahspan-modules": "^0.6.5",
"axios": "^1.7.9",
"reflect-metadata": "^0.1.14",
"rxjs": "^7.8.1",

78
api/src/app.controller.ts Normal file
View File

@@ -0,0 +1,78 @@
import {
Controller,
Get,
Headers,
Query,
StreamableFile,
UseGuards
} from '@nestjs/common';
// import { Client as MsGraphClient } from '@microsoft/microsoft-graph-client';
import { MsGraphService } from '@noahspan/noahspan-modules'
@Controller()
export class AppController {
constructor(
private readonly msGraphService: MsGraphService
) {}
@Get('userPhoto')
async getProfilePhoto(@Headers() headers: any): Promise<StreamableFile> {
// try {
// const graphToken: string = await this.msGraphService.getMsGraphAuth(
// headers.authorization.replace('Bearer ', ''),
// ['user.read']
// );
// const client: MsGraphClient =
// await this.msGraphService.getMsGraphClientDelegated(graphToken);
// const blob: Blob = await client.api(`me/photos('48x48')/$value`).get();
// const arrayBuffer: ArrayBuffer = await blob.arrayBuffer();
// const buffer: Buffer = Buffer.from(arrayBuffer);
// return new StreamableFile(buffer, {
// type: 'application/json',
// disposition: `attachment; filename="user_photo.png"`
// });
// } catch (error) {
// return error;
// }
try {
const buffer = await this.msGraphService.getProfilePhoto(
headers.authorization.replace('Bearer ', ''),
['user.read']
)
return new StreamableFile(buffer, {
type: 'application/json',
disposition: `attachment; filename="user_photo.png"`
});
} catch (error) {
return error;
}
}
@Get('userProfile')
async getUserProfile(@Headers() headers: any): Promise<any> {
// try {
// const graphToken: string = await this.msGraphService.getMsGraphAuth(
// headers.authorization.replace('Bearer ', ''),
// ['user.read']
// );
// const client: MsGraphClient =
// await this.msGraphService.getMsGraphClientDelegated(graphToken);
// const userProfile = await client.api(`me`).get();
// return userProfile;
// } catch (error) {
// return error;
// }
try {
const userProfile = await this.msGraphService.getUserProfile(headers.authorization.replace('Bearer ', ''));
return userProfile;
} catch (error) {
return error;
}
}
}

View File

@@ -1,18 +1,50 @@
import { Module } from '@nestjs/common';
import { GitHubApiModule } from './github/github.module';
import { APP_FILTER } from '@nestjs/core';
import { APP_FILTER, APP_GUARD } from '@nestjs/core';
import { HttpExceptionFilter } from './filters/http-exception.filter';
import { ProjectModule } from './project/project.module';
import { AuthGuard, AuthModule, MsGraphModule } from '@noahspan/noahspan-modules'
import { ConfigModule, ConfigService } from '@nestjs/config';
import configuration from './config/configuration';
import { AppController } from './app.controller';
@Module({
imports: [
GitHubApiModule,
AuthModule.registerAsync({
inject: [ConfigService],
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => {
return {
clientId: configService.get<string>('clientId'),
clientSecret: configService.get<string>('clientSecret'),
tenantId: configService.get<string>('tenantId')
}
}
}),
ConfigModule.forRoot({
load: [configuration]
}),
MsGraphModule.registerAsync({
inject: [ConfigService],
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => {
return {
clientId: configService.get<string>('clientId'),
clientSecret: configService.get<string>('clientSecret'),
tenantId: configService.get<string>('tenantId')
}
}
}),
ProjectModule
],
controllers: [AppController],
providers: [
{
provide: APP_FILTER,
useClass: HttpExceptionFilter
},
{
provide: APP_GUARD,
useClass: AuthGuard
}
]
})

View File

@@ -1,4 +1,5 @@
export default () => ({
githubApiUsername: process.env.GITHUB_API_USERNAME,
githubApiPassword: process.env.GITHUB_API_PAT
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
tenantId: process.env.TENANT_ID
})

View File

@@ -6,12 +6,13 @@ import {
HttpException,
Param,
Post,
Put
Put,
UseGuards
} from '@nestjs/common';
import { ProjectDto } from './project.dto';
import { Project } from './project.entity';
import { ProjectService } from './project.service';
import { CustomError } from '@noahspan/noahspan-modules';
import { CustomError, Public } from '@noahspan/noahspan-modules';
@Controller('projects')
export class ProjectController {
@@ -31,6 +32,7 @@ export class ProjectController {
}
}
@Public()
@Get()
async findAll() {
try {