initial launch

This commit is contained in:
2025-02-23 19:35:44 -06:00
parent ce334cb7fd
commit 12101ce409
18 changed files with 159 additions and 247 deletions

View File

@@ -28,10 +28,10 @@
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@noahspan/azure-database": "^3.1.2",
"@noahspan/noahspan-modules": "^0.6.5",
"@noahspan/noahspan-modules": "^1.0.0",
"axios": "^1.7.9",
"reflect-metadata": "^0.1.14",
"rxjs": "^7.8.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"uuid": "^11.0.5"
},
"devDependencies": {

View File

@@ -1,78 +0,0 @@
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

@@ -2,10 +2,9 @@ import { Module } from '@nestjs/common';
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 { AuthGuard, AuthModule, UserModule } from '@noahspan/noahspan-modules'
import { ConfigModule, ConfigService } from '@nestjs/config';
import configuration from './config/configuration';
import { AppController } from './app.controller';
@Module({
imports: [
@@ -23,7 +22,7 @@ import { AppController } from './app.controller';
ConfigModule.forRoot({
load: [configuration]
}),
MsGraphModule.registerAsync({
UserModule.registerAsync({
inject: [ConfigService],
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => {
@@ -36,7 +35,6 @@ import { AppController } from './app.controller';
}),
ProjectModule
],
controllers: [AppController],
providers: [
{
provide: APP_FILTER,

View File

@@ -1,4 +1,5 @@
export default () => ({
azureStorageConnectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
tenantId: process.env.TENANT_ID