Skip to content

Commit

Permalink
Merging some stuff
Browse files Browse the repository at this point in the history
Merge branch 'main' of ssh://github.com/CSSE6400/P01-UniBasement
  • Loading branch information
JTrenerry committed Apr 24, 2024
2 parents 15b2fb2 + b8a13d1 commit 8fa63fb
Show file tree
Hide file tree
Showing 36 changed files with 190 additions and 2,618 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v3

# Install Node.js and cache dependencies
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

# Run frontend build and test
- name: Build and test
run: |
npm ci
npm run build --if-present
npm test
working-directory: frontend
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# UniBasement
### [Architecture](ARCHITECTURE.md) | [Handshake](HANDSHAKE.md) | [AI](AI.md)
### [Architecture](docs/ARCHITECTURE.md) | [Handshake](docs/HANDSHAKE.md) | [Database](docs/DATABASE.md) | [AI](docs/AI.md)

## Description
UniBasement is designed to empower students to understand the concepts in a deeper manner, at the forefront of the platform is the desire to enable students to have a deeper understanding of the content they are taught and to work with their peers to develop their collective understanding. Within the modern world, studying is more than ever stressful and makes student anxious, easy access to materials to enable students to study in a more effective manner is essential and UniBasement intends to make studying for final exams an easier affair.
Expand Down
1 change: 0 additions & 1 deletion backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
package-lock.json
5 changes: 0 additions & 5 deletions backend/.env

This file was deleted.

8 changes: 6 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ FROM node:latest

WORKDIR /app

COPY . /app
COPY ./package.json /app
COPY ./package-lock.json /app
RUN npm ci

RUN npm install
COPY ./index.ts .
COPY ./db ./db
COPY ./routes ./routes

CMD ["npm", "run", "start"]
2 changes: 0 additions & 2 deletions backend/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Imports
import { Pool } from 'pg'

const dotenv = require('dotenv');

const pool = new Pool({
user: process.env.DB_USER,
host: process.env.DB_HOST,
Expand Down
6 changes: 3 additions & 3 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ services:
db:
image: postgres:latest
environment:
DB_USER: "postgres"
DB_PASSWORD: "postgres"
DB_DATABASE: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DATABASE: "postgres"

adminer:
image: adminer
Expand Down
4 changes: 0 additions & 4 deletions backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import cors from 'cors';
import { routes } from './routes/index';
import * as db from './db/index';

const dotenv = require('dotenv');

dotenv.config();

const PORT: number = process.env.PORT ? parseInt(process.env.PORT) : 8080;

// Make the app
Expand Down
13 changes: 0 additions & 13 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@types/pg": "^8.11.5",
"@types/uuid": "^9.0.8",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"pg": "^8.11.5",
"uuid": "^9.0.1"
Expand Down
8 changes: 6 additions & 2 deletions backend/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const router = Router();
* See outputs and params in HANDSHAKE.md
*
*/

// Comments by question id
router.get('/questions/:questionId', async (req: Request, res: Response) => {
const questionID = req.params.questionId;
Expand Down Expand Up @@ -113,8 +114,9 @@ router.get('/evan', async (req: Request, res: Response) => {
res.status(200).json('Evan is the best');
});

// Helper functions
// Interfaces

// Used in nest helper function
interface CommentObject {
commentsid: number;
parentcommentid: number | null;
Expand All @@ -129,7 +131,9 @@ interface CommentObject {
children?: CommentObject[];
}

// Recursive function to nest comments into their parent comments
// Helper functions

// Function to nest comments into their parent comments
function nest(jsonData: any[]) {
const dataDict: { [id: number]: CommentObject } = {};
jsonData.forEach(item => dataDict[item.commentsid] = item);
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions docs/DATABASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# TODO

# Courses
| Name | Type | Description | other |
|----|----|----|----|
| courseCode | VARCHAR(8) | The Course Code for a course i.e. CSSE6400 | key |
| courseName | meow | The name of the course i.e. Software Architecture | None |
| courseDescription | meow | A description for the course | None |

# Exams
| Name | Type | Description | other |
|----|----|----|----|
| coursecode | VARCHAR(8) | The Course Code for a course i.e. CSSE6400 | reference to courses table |
| examId | Serial | Just the id for the database | key |

# Questions
| Name | Type | Description | other |
|----|----|----|----|
| examId | Serial | Just the id for the exams database | reference to the exams table |
| questionId | Serial | Just the id for the database | key |

# Comments
| Name | Type | Description | other |
|----|----|----|----|
| questionId | Serial | Just the id for the questions database | reference to the questions table |
| commentsId | Serial | Just the id for the database | key |
2 changes: 1 addition & 1 deletion HANDSHAKE.md → docs/HANDSHAKE.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ None
}
]
```
# /exams/:examid/:questionid GET
# /questions/:questionid GET NEEDS UPDATING
### Path params:
| Name | Description |
|----|----|
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion frontend/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const withMDX = nextMDX({
/** @type {import('next').NextConfig} */
const nextConfig = {
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'mdx'],
output: 'export',
basePath: '/UniBasement',
images: {
unoptimized: true,
Expand Down
Loading

0 comments on commit 8fa63fb

Please sign in to comment.