Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
ad76568
postgres setup + onboarding steps
huang0h Sep 8, 2024
d92dddb
add pantries + donations tables
huang0h Sep 16, 2024
ed4e0d7
fix migrations
huang0h Sep 16, 2024
be7b976
Merge pull request #1 from Code-4-Community/ah/add-tables
huang0h Sep 16, 2024
0086a3c
New icon
nadishiro17 Sep 20, 2024
017816c
Changed favicon and page title to SSF
nadishiro17 Sep 20, 2024
32910da
Changed favicon and page title to SSF
nadishiro17 Sep 20, 2024
2788491
color theme, chakra, food request page
CerberusLatrans Sep 22, 2024
2db6cc4
food item section
CerberusLatrans Sep 22, 2024
7760096
created and added header component to root
denniwang Sep 23, 2024
fa613b3
Remove test page
sam-schu Sep 22, 2024
090e498
Add new pages
sam-schu Sep 22, 2024
d31a1ec
Add routes for new pages
sam-schu Sep 23, 2024
0f70788
Remove template test file
sam-schu Sep 23, 2024
626b38b
Merge pull request #2 from Code-4-Community/sts/initial-routes
sam-schu Sep 29, 2024
aa911a6
fix formatting, json formdata
CerberusLatrans Oct 4, 2024
bbccb08
fix theme colors
CerberusLatrans Oct 4, 2024
6454bbb
Merge remote-tracking branch 'origin/main' into OT.FoodRequestForm
CerberusLatrans Oct 4, 2024
705fc46
Update index.html
nadishiro17 Oct 8, 2024
b3dc6fd
Merge pull request #5 from Code-4-Community/OT.FoodRequestForm
CerberusLatrans Oct 9, 2024
e1c2a2b
Merge pull request #7 from Code-4-Community/change-favicon-title
fanzzz368 Oct 12, 2024
fe6d4ce
Merge branch 'Code-4-Community:main' into main
huang0h Oct 13, 2024
885105a
Merge branch 'Code-4-Community:main' into main
huang0h Oct 13, 2024
d1967e1
Merge branch 'Code-4-Community:main' into main
huang0h Oct 13, 2024
6cebad0
changed from h2 to h1
denniwang Oct 16, 2024
6bce36b
Merge pull request #6 from Code-4-Community/header
denniwang Oct 21, 2024
d4d8384
cognito auth
fanzzz368 Nov 3, 2024
68400ce
update donations table
fanzzz368 Dec 2, 2024
a0cc139
Merge pull request #16 from Code-4-Community/donations-table-update
fanzzz368 Dec 6, 2024
ca7db49
add/revise db tables
fanzzz368 Jan 19, 2025
8f34e31
Merge pull request #17 from Code-4-Community/update-database-schema
fanzzz368 Jan 19, 2025
09f77a7
Initial commit for this branch
dburkhart07 Jan 20, 2025
5418ccb
allow one user to have multiple roles
fanzzz368 Jan 20, 2025
c9f7f40
Merge pull request #18 from Code-4-Community/update-database-schema
fanzzz368 Jan 20, 2025
4d303ea
food request modal and button, updated form contents
Juwang110 Jan 21, 2025
a107a3c
fixed migrations (drop previous users, pantries, and donations table …
fanzzz368 Jan 22, 2025
e35963c
Merge pull request #19 from Code-4-Community/update-database-schema
fanzzz368 Jan 22, 2025
28951ee
Updated design for request forms page
dburkhart07 Jan 22, 2025
0fc781d
remove unecessary form data, made component into a button to be used …
Juwang110 Jan 22, 2025
fb3fc5f
Merge branch 'main' into food-request-form
Juwang110 Jan 22, 2025
d6ccd89
backend post form route working, created food requests backend folder…
Juwang110 Jan 22, 2025
69cb73e
Merge pull request #12 from Code-4-Community/cognito
fanzzz368 Jan 23, 2025
11730b3
Renamed frontend component to RequestForms (Admin dashboard of all ac…
dburkhart07 Jan 24, 2025
6c78018
Completed frontend, just need to incorporate backend APIs into it
dburkhart07 Jan 24, 2025
22b7000
fixed submit button orientation, added description to form, deleted o…
Juwang110 Jan 24, 2025
ffae96e
Updated dashboard to properly get the requests by pantryId in database
dburkhart07 Jan 24, 2025
dc088a8
remove old form route
Juwang110 Jan 24, 2025
bac85b2
Updated API endpoint for confirm delivery and added previous order fu…
dburkhart07 Jan 25, 2025
d3e98c2
fix form submission bug
Juwang110 Jan 25, 2025
3fcced8
Fixed confirming delivery dates, previous requests, and smaller featu…
dburkhart07 Jan 26, 2025
5ce06a1
Final push for branch
dburkhart07 Jan 26, 2025
2389fb3
Fixed final aspects of deliveryConfirmation
dburkhart07 Jan 26, 2025
263113b
change to each user can only have one role
fanzzz368 Jan 25, 2025
b38e2fc
update pantries db
fanzzz368 Jan 26, 2025
c513598
Merge pull request #22 from Code-4-Community/update-database-schema
fanzzz368 Jan 26, 2025
bd48e43
adding api body for documentation in swagger
Juwang110 Jan 26, 2025
e7af090
initial frontend for pantry dashboard
Juwang110 Jan 27, 2025
067c220
Pulled changes from food-request
dburkhart07 Jan 27, 2025
9e93647
Created base64 encoding for uploaded photos
dburkhart07 Jan 27, 2025
4d1050b
backend setup for pantries
Juwang110 Jan 28, 2025
564d232
working get ssf rep route from frontend dashboard
Juwang110 Jan 29, 2025
e14c427
Logic for AWS S3 photo uploads and paths saved to database
dburkhart07 Jan 29, 2025
d941aa3
Updated pantry approval in database
dburkhart07 Jan 29, 2025
8724eae
Attempted to fix AWS photo sending, did not work
dburkhart07 Jan 30, 2025
4a0f069
refactor dashboard routes and visuals, abstract out types into types …
Juwang110 Jan 30, 2025
70c240b
Fixed PR suggested changes
dburkhart07 Feb 1, 2025
aea2c59
Merge pull request #20 from Code-4-Community/food-request-form
Juwang110 Feb 1, 2025
3c9498d
Finished PR changes
dburkhart07 Feb 1, 2025
5f229b1
Finalized AWS photo uploads
dburkhart07 Feb 2, 2025
549f512
Cleaned up code for consistency
dburkhart07 Feb 2, 2025
f16ad86
Fixing styling of request form page
dburkhart07 Feb 2, 2025
a1ae283
Fixed formattings
dburkhart07 Feb 2, 2025
b285c5e
Fixed code format
dburkhart07 Feb 2, 2025
c2c433c
Fixed backend alerting
dburkhart07 Feb 3, 2025
806ea34
Removed unwanted binary files
dburkhart07 Feb 3, 2025
6f0e232
Removed unwanted binary files
dburkhart07 Feb 3, 2025
9361a32
Fixed optional photo uploading
dburkhart07 Feb 5, 2025
faae974
clean up, fix types and minor logic errors
Juwang110 Feb 6, 2025
e724faa
Merge pull request #21 from Code-4-Community/confirm-food-delivered
dburkhart07 Feb 7, 2025
9b219b5
Initial pull from updated main
dburkhart07 Feb 7, 2025
bed0e7e
Finished backend component, began frontend, currently retrieving data…
dburkhart07 Feb 7, 2025
e305b61
Finished page layout for PR
dburkhart07 Feb 9, 2025
0bc8aa9
Added additional filtering
dburkhart07 Feb 9, 2025
a0f129d
move pantry dashboard route logic to apiClient for simplicity
Juwang110 Feb 10, 2025
13f1b82
fixing merge conflic dependencies
Juwang110 Feb 11, 2025
f02335b
fix yarn
Juwang110 Feb 11, 2025
a7643f4
Merge branch 'main' into pantry-dashboard
Juwang110 Feb 11, 2025
883fc76
Updated PR review changes
dburkhart07 Feb 14, 2025
e621311
Final Changes for the PR Review
dburkhart07 Feb 14, 2025
d0dca57
add pantry id to url for modularity
Juwang110 Feb 16, 2025
9bb10a2
Merge pull request #24 from Code-4-Community/pantry-dashboard
Juwang110 Feb 16, 2025
bafeeb2
Merge branch 'main' into approve-pantry-request
dburkhart07 Feb 17, 2025
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=securing-safe-food
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=PLACEHOLDER_PASSWORD
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ Thumbs.db
# Environment file
*.env
*.env.*
!.env.example
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
# Scaffolding
# Securing Safe Food

<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>

✨ **This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)** ✨

## Environment Setup

Install app dependencies by running this at the repo root (`ssf`)

```
yarn install
```

To setup your backend, follow the backend-specific instructions [here](apps/backend/README.md)

*Note: you may need to prefix your `nx` commands with `npx`. For example, to serve the frontend, if:
```
nx serve frontend
```

doesn't work, try:

```
npx nx serve frontend
```

## Start the app

To start the development server run `nx serve frontend`. Open your browser and navigate to http://localhost:4200/. Happy coding!
Expand Down
28 changes: 28 additions & 0 deletions apps/backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Backend Setup

This part can be a little tricky! If you run into some confusing errors along the way, don't be afraid to reach out if have any trouble!

You'll need to download:

1. [PostgreSQL](https://www.postgresql.org/download/)
2. [PgAdmin 4](https://www.pgadmin.org/download/) (if PostgreSQL didn't come with it)

Then, set up a database called `securing-safe-food`. If you're not familiar with how to do so, it's easy to do through PgAdmin

1. Open PgAdmin and configure your credentials (if necessary). Then, right click on the `Databases` dropdown (under `Servers` > `PostgreSQL [version]`)

![alt text](resources/pg-setup-1.png)

2. Enter "securing-safe-food" as the database name

![alt text](resources/pg-setup-2.png)

Next, create a file called `.env` in the **root directory** (under `ssf/`) and copy over the contents from `.env.example`. Replace `DATABASE_PASSWORD` with the password you entered for the `postgres` user (NOT necessarily your PgAdmin master password!)

You can check that your database connection details are correct by running `nx serve backend` - if you can see the following line in the terminal, then you've got it right!

```
"LOG 🚀 Application is running on: http://localhost:3000/api"
```

Finally, run `yarn run typeorm:migrate` to load all the tables into your database. If everything is set up correctly, you should see "Migration ... has been executed successfully." in the terminal.
Binary file added apps/backend/resources/pg-setup-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/backend/resources/pg-setup-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 20 additions & 14 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { RequestsModule } from './foodRequests/request.module';
import { PantriesModule } from './pantries/pantries.module';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UsersModule } from './users/users.module';
import { AuthModule } from './auth/auth.module';
import { PluralNamingStrategy } from './strategies/plural-naming.strategy';
import { PantriesModule } from './pantries/pantries.module';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { MulterModule } from '@nestjs/platform-express';
import typeorm from './config/typeorm';

@Module({
imports: [
TypeOrmModule.forRoot({
type: 'mongodb',
host: '127.0.0.1',
port: 27017,
database: 'c4cOpsTest',
// username: 'root',
// password: 'root',
autoLoadEntities: true,
// entities: [join(__dirname, '**/**.entity.{ts,js}')],
// Setting synchronize: true shouldn't be used in production - otherwise you can lose production data
synchronize: true,
namingStrategy: new PluralNamingStrategy(),
MulterModule.register({
dest: './uploads',
}),
ConfigModule.forRoot({
isGlobal: true,
load: [typeorm],
}),
TypeOrmModule.forRootAsync({
inject: [ConfigService],
useFactory: async (configService: ConfigService) =>
configService.get('typeorm'),
}),
UsersModule,
AuthModule,
PantriesModule,
RequestsModule,
PantriesModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
10 changes: 1 addition & 9 deletions apps/backend/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
BadRequestException,
Body,
Controller,
Post,
Request,
UseGuards,
} from '@nestjs/common';
import { BadRequestException, Body, Controller, Post } from '@nestjs/common';

import { SignInDto } from './dtos/sign-in.dto';
import { SignUpDto } from './dtos/sign-up.dto';
Expand All @@ -16,7 +9,6 @@ import { DeleteUserDto } from './dtos/delete-user.dto';
import { User } from '../users/user.entity';
import { SignInResponseDto } from './dtos/sign-in-response.dto';
import { RefreshTokenDto } from './dtos/refresh-token.dto';
import { AuthGuard } from '@nestjs/passport';
import { ConfirmPasswordDto } from './dtos/confirm-password.dto';
import { ForgotPasswordDto } from './dtos/forgot-password.dto';

Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { SignInDto } from './dtos/sign-in.dto';
import { SignInResponseDto } from './dtos/sign-in-response.dto';
import { createHmac } from 'crypto';
import { RefreshTokenDto } from './dtos/refresh-token.dto';
import { Status } from '../users/types';
import { Role } from '../users/types';
import { ConfirmPasswordDto } from './dtos/confirm-password.dto';

@Injectable()
Expand Down Expand Up @@ -60,7 +60,7 @@ export class AuthService {

async signup(
{ firstName, lastName, email, password }: SignUpDto,
status: Status = Status.STANDARD,
role: Role = Role.VOLUNTEER,
): Promise<boolean> {
// Needs error handling
const signUpCommand = new SignUpCommand({
Expand All @@ -77,7 +77,7 @@ export class AuthService {
// If you choose to do so, you'll have to first add this custom attribute in your user pool
{
Name: 'custom:role',
Value: status,
Value: role,
},
],
});
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/auth/aws-exports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const CognitoAuthConfig = {
userPoolId: 'USER POOL ID HERE',
clientId: 'CLIENT ID HERE',
region: 'us-east-2',
userPoolId: 'us-east-1_oshVQXLX6',
clientId: '42bfm2o2pmk57mpm5399s0e9no',
region: 'us-east-1',
};

export default CognitoAuthConfig;
10 changes: 10 additions & 0 deletions apps/backend/src/aws/aws-s3.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Global, Module } from '@nestjs/common';
import { AWSS3Service } from './aws-s3.service';

@Global()
@Module({
imports: [],
providers: [AWSS3Service],
exports: [AWSS3Service],
})
export class AWSS3Module {}
48 changes: 48 additions & 0 deletions apps/backend/src/aws/aws-s3.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Injectable } from '@nestjs/common';
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';

@Injectable()
export class AWSS3Service {
private client: S3Client;
private readonly bucket: string;
private readonly region: string;

constructor() {
this.region = process.env.AWS_REGION || 'us-east-2';
this.bucket = process.env.AWS_BUCKET_NAME;
if (!this.bucket) {
throw new Error('AWS_BUCKET_NAME is not defined');
}
this.client = new S3Client({
region: this.region,
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
},
});
}

async upload(files: Express.Multer.File[]): Promise<string[]> {
const uploadedFileUrls: string[] = [];
try {
for (const file of files) {
const fileName = file.originalname;

const command = new PutObjectCommand({
Bucket: this.bucket,
Key: fileName,
Body: file.buffer,
ContentType: file.mimetype || 'application/octet-stream',
});

await this.client.send(command);

const url = `https://${this.bucket}.s3.${this.region}.amazonaws.com/${fileName}`;
uploadedFileUrls.push(url);
}
return uploadedFileUrls;
} catch (error) {
throw new Error('File upload to AWS failed');
}
}
}
36 changes: 36 additions & 0 deletions apps/backend/src/config/typeorm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { registerAs } from '@nestjs/config';
import { PluralNamingStrategy } from '../strategies/plural-naming.strategy';
import { DataSource, DataSourceOptions } from 'typeorm';
import { User1725726359198 } from '../migrations/1725726359198-User';
import { AddTables1726524792261 } from '../migrations/1726524792261-addTables';
import { ReviseTables1737522923066 } from '../migrations/1737522923066-reviseTables';
import { UpdateUserRole1737816745912 } from '../migrations/1737816745912-UpdateUserRole';
import { UpdatePantriesTable1737906317154 } from '../migrations/1737906317154-updatePantriesTable';
import { UpdatePantriesTable1738172265266 } from '../migrations/1738172265266-updatePantriesTable';
import { UpdatePantriesTable1739056029076 } from '../migrations/1739056029076-updatePantriesTable';

const config = {
type: 'postgres',
host: `${process.env.DATABASE_HOST}`,
port: parseInt(`${process.env.DATABASE_PORT}`, 10),
database: `${process.env.DATABASE_NAME}`,
username: `${process.env.DATABASE_USERNAME}`,
password: `${process.env.DATABASE_PASSWORD}`,
autoLoadEntities: true,
synchronize: false,
namingStrategy: new PluralNamingStrategy(),
// Glob patterns (e.g. ../migrations/**.ts) are deprecated, so we have to manually specify each migration
// TODO: see if there's still a way to dynamically load all migrations
migrations: [
User1725726359198,
AddTables1726524792261,
ReviseTables1737522923066,
UpdateUserRole1737816745912,
UpdatePantriesTable1737906317154,
UpdatePantriesTable1738172265266,
UpdatePantriesTable1739056029076,
],
};

export default registerAs('typeorm', () => config);
export const connectionSource = new DataSource(config as DataSourceOptions);
Loading