Skip to content

Commit

Permalink
Revert "Implemented basic backend for notifications"
Browse files Browse the repository at this point in the history
This reverts commit f831432.
  • Loading branch information
josieek committed Nov 13, 2024
1 parent f831432 commit 9772bdd
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 152 deletions.
3 changes: 1 addition & 2 deletions backend/dist/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ const common_1 = require("@nestjs/common");
const auth_module_1 = require("./auth/auth.module");
const user_module_1 = require("./user/user.module");
const grant_module_1 = require("./grant/grant.module");
const notification_module_1 = require("./notifications/notification.module");
let AppModule = class AppModule {
};
AppModule = __decorate([
(0, common_1.Module)({
imports: [auth_module_1.AuthModule, user_module_1.UserModule, grant_module_1.GrantModule, notification_module_1.NotificationsModule],
imports: [auth_module_1.AuthModule, user_module_1.UserModule, grant_module_1.GrantModule],
})
], AppModule);
exports.AppModule = AppModule;
12 changes: 0 additions & 12 deletions backend/dist/auth/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ let AuthController = class AuthController {
async setNewPassword(newPassword, session, username, email) {
return await this.authService.setNewPassword(newPassword, session, username, email);
}
async updateProfile(username, displayName) {
await this.authService.updateProfile(username, displayName);
return { message: 'Profile has been updated' };
}
};
__decorate([
(0, common_1.Post)('register'),
Expand Down Expand Up @@ -62,14 +58,6 @@ __decorate([
__metadata("design:paramtypes", [String, String, String, String]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "setNewPassword", null);
__decorate([
(0, common_1.Post)('update-profile'),
__param(0, (0, common_1.Body)('username')),
__param(1, (0, common_1.Body)('displayName')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "updateProfile", null);
AuthController = __decorate([
(0, common_1.Controller)('auth'),
__metadata("design:paramtypes", [auth_service_1.AuthService])
Expand Down
47 changes: 7 additions & 40 deletions backend/dist/auth/auth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ exports.AuthService = void 0;
const common_1 = require("@nestjs/common");
const aws_sdk_1 = __importDefault(require("aws-sdk"));
const crypto = __importStar(require("crypto"));
aws_sdk_1.default.config.update({
region: process.env.AWS_REGION,
});
let AuthService = AuthService_1 = class AuthService {
constructor() {
this.logger = new common_1.Logger(AuthService_1.name);
Expand Down Expand Up @@ -184,28 +187,14 @@ let AuthService = AuthService_1 = class AuthService {
.promise();
user = newUser;
}
return { access_token: idToken, user, message: "Login Successful!" };
return { access_token: idToken, user };
}
catch (error) {
/* Login Failures */
const cognitoError = error;
if (cognitoError.code) {
switch (cognitoError.code) {
case 'NotAuthorizedException':
this.logger.warn(`Login failed: ${cognitoError.message}`);
throw new common_1.UnauthorizedException('Incorrect username or password.');
default:
this.logger.error(`Login failed: ${cognitoError.message}`, cognitoError.stack);
throw new common_1.InternalServerErrorException('An error occurred during login.');
}
}
else if (error instanceof Error) {
// Handle non-AWS errors
if (error instanceof Error) {
this.logger.error('Login failed', error.stack);
throw new common_1.InternalServerErrorException(error.message || 'Login failed.');
throw new Error(error.message || 'Login failed');
}
// Handle unknown errors
throw new common_1.InternalServerErrorException('An unknown error occurred during login.');
throw new Error('An unknown error occurred during login');
}
}
async setNewPassword(newPassword, session, username, email) {
Expand Down Expand Up @@ -249,28 +238,6 @@ let AuthService = AuthService_1 = class AuthService {
throw new Error('An unknown error occurred');
}
}
async updateProfile(username, displayName) {
try {
const tableName = process.env.DYNAMODB_USER_TABLE_NAME || 'TABLE_FAILURE';
const params = {
TableName: tableName,
Key: { userId: username },
UpdateExpression: 'set displayName = :displayName',
ExpressionAttributeValues: {
':displayName': displayName
},
};
await this.dynamoDb.update(params).promise();
this.logger.log(`User ${username} updated user profile.`);
}
catch (error) {
if (error instanceof Error) {
this.logger.error('Updating the profile failed', error.stack);
throw new Error(error.message || 'Updating the profile failed');
}
throw new Error('An unknown error occurred');
}
}
};
AuthService = AuthService_1 = __decorate([
(0, common_1.Injectable)()
Expand Down
4 changes: 1 addition & 3 deletions backend/dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const aws_sdk_1 = __importDefault(require("aws-sdk"));
/* ! */
async function bootstrap() {
aws_sdk_1.default.config.update({
region: process.env.AWS_REGION,
accessKeyId: process.env.OPEN_HATCH,
secretAccessKey: process.env.CLOSED_HATCH
region: process.env.AWS_REGION
});
const app = await core_1.NestFactory.create(app_module_1.AppModule);
app.enableCors();
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { AuthModule } from './auth/auth.module';
import { UserModule } from './user/user.module';
import { GrantModule } from './grant/grant.module';
import { NotificationsModule } from './notifications/notification.module';
import { NotificationsModule } from './notifications/notifications.module';

@Module({
imports: [AuthModule, UserModule, GrantModule, NotificationsModule],
Expand Down
55 changes: 0 additions & 55 deletions backend/src/notifications/notifcation.service.ts

This file was deleted.

14 changes: 14 additions & 0 deletions backend/src/notifications/notifcations.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// src/notifications/notifications.service.ts
import { Injectable } from '@nestjs/common';
import * as AWS from 'aws-sdk';

// idk about name but maybe?
const TABLE_NAME = 'BCANNotifications';

@Injectable()
export class NotificationsService {

// function to make a notification

// function to find notifications by user id
}
22 changes: 0 additions & 22 deletions backend/src/notifications/notification.controller.ts

This file was deleted.

6 changes: 0 additions & 6 deletions backend/src/notifications/notification.model.ts

This file was deleted.

11 changes: 0 additions & 11 deletions backend/src/notifications/notification.module.ts

This file was deleted.

17 changes: 17 additions & 0 deletions backend/src/notifications/notifications.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// src/notifications/notifications.controller.ts
import { Controller, Post, Body, Get, Query } from '@nestjs/common';

@Controller('notifications')
export class NotificationsController {
// constructor(private readonly notificationsService: NotificationsService) {}

@Post()
async create(@Body() notification: Partial<Notification>) {
// return this.notificationsService.create(notification);
}

@Get()
async findByUser(@Query('userId') userId: string) {
// return this.notificationsService.findByUser(userId);
}
}
11 changes: 11 additions & 0 deletions backend/src/notifications/notifications.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// src/notifications/notifications.module.ts
import { Module } from '@nestjs/common';
import { NotificationsController } from './notifications.controller';
import { NotificationsService } from './notifcations.service';

@Module({
providers: [NotificationsService],
controllers: [NotificationsController],
exports: [NotificationsService],
})
export class NotificationsModule {}

0 comments on commit 9772bdd

Please sign in to comment.