Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/api GUYS, EPIC PR, PLEASE CHECKOUT ‼️ #124

Merged
merged 162 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
7688a32
Updated README.md file
joebaillie21 Oct 27, 2023
093c8a7
created user.ts file and seed data code.
joebaillie21 Oct 27, 2023
791eafe
Updated seed data
joebaillie21 Oct 28, 2023
4a0c0dd
Updated README.md with file structure
joebaillie21 Oct 28, 2023
2ee044f
Added assignments to seed data
joebaillie21 Oct 28, 2023
7b22f6e
Added uniqueness to fields
joebaillie21 Oct 28, 2023
946fc07
Seed data for officer position
joebaillie21 Oct 28, 2023
ac6fa75
Officer Position Seed Data complete
joebaillie21 Oct 28, 2023
2ec5bd9
first officer test data added
joebaillie21 Oct 28, 2023
a693354
officer seed data completed
joebaillie21 Oct 28, 2023
b926fa1
Seed data for users and mentors
joebaillie21 Oct 28, 2023
05d4755
Skill seed data added
joebaillie21 Oct 28, 2023
0266b60
Added Mentor Skill seed data
joebaillie21 Oct 28, 2023
af237b9
Added Course seed data
joebaillie21 Oct 28, 2023
6cf2977
Added CourseTaken seed data
joebaillie21 Oct 28, 2023
f6f6fe9
Fixed officer seeding
joebaillie21 Oct 30, 2023
b760f58
Added quote seed
joebaillie21 Oct 30, 2023
b70bdd0
Seed data done
joebaillie21 Nov 4, 2023
76be7dd
Seed data updates
joebaillie21 Nov 4, 2023
9a84c7a
seed data function updates
joebaillie21 Nov 4, 2023
28180bf
add author to readme
PokeJofeJr4th Nov 4, 2023
370210a
Added author name
grong0 Nov 4, 2023
5827245
Author Update
grong0 Nov 4, 2023
ae4b475
claim department api task
PokeJofeJr4th Nov 4, 2023
f96a268
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
PokeJofeJr4th Nov 4, 2023
cda195a
Assignments updated
joebaillie21 Nov 4, 2023
90add26
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
joebaillie21 Nov 4, 2023
8ec7095
added assignment to quote api
Nov 4, 2023
8d24679
accepted merge and assigned name to quote api
Nov 4, 2023
c4da16c
fixed name in lib/README
Nov 4, 2023
caeceb9
restored branch to status prior to hapi install
joebaillie21 Nov 4, 2023
b53b070
read me update
Nov 4, 2023
0e04619
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
joebaillie21 Nov 4, 2023
fca4f7e
Merge branch 'dev/api' of https://github.com/rit-s
joebaillie21 Nov 4, 2023
ee993b4
Restore to pre-hapi
joebaillie21 Nov 4, 2023
66258d3
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
joebaillie21 Nov 4, 2023
20ee007
readme update
Nov 4, 2023
776633d
add route to get all departments
PokeJofeJr4th Nov 4, 2023
730c1b4
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
PokeJofeJr4th Nov 4, 2023
88ed1ae
update selection object for departments/GET
PokeJofeJr4th Nov 4, 2023
a19a562
schema and seed data updated
joebaillie21 Nov 4, 2023
2c7c4c6
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
joebaillie21 Nov 4, 2023
e86d897
updated api
joebaillie21 Nov 4, 2023
702f939
move
joebaillie21 Nov 4, 2023
5e0c75d
moved schtuff
joebaillie21 Nov 4, 2023
647c7f5
fixed shortTitle error
joebaillie21 Nov 4, 2023
12edb25
added get all quotes with user relation
Nov 4, 2023
925c9f4
Get methods for golinks active
joebaillie21 Nov 4, 2023
ffdfebd
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
joebaillie21 Nov 4, 2023
25f4673
full CRUD the departments
PokeJofeJr4th Nov 4, 2023
99d4b09
officer route
Nov 4, 2023
9772fe8
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
PokeJofeJr4th Nov 4, 2023
339b27a
finish departments API (not tested yet)
PokeJofeJr4th Nov 11, 2023
101ff50
validate department ID
PokeJofeJr4th Nov 11, 2023
41821e8
add null checks for departments api
PokeJofeJr4th Nov 11, 2023
1a54ea3
added golink api post
Nov 11, 2023
15739ce
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
Nov 11, 2023
b81b0ce
add comments and update response code for departments API
PokeJofeJr4th Nov 11, 2023
6ebb43d
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
PokeJofeJr4th Nov 11, 2023
325eb80
add mentor routes API
PokeJofeJr4th Nov 11, 2023
1e52524
fix DELETE to `/api/departments/` - delete courses in the department
PokeJofeJr4th Nov 18, 2023
0c8ebc6
update response codes and error states for Departments route
PokeJofeJr4th Nov 18, 2023
dc94f57
add Course API routes
PokeJofeJr4th Nov 18, 2023
2dee272
Mentor delete with error handling completed
joebaillie21 Nov 18, 2023
6d47ea8
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
joebaillie21 Nov 18, 2023
30bfddd
added select and insert functionality to quote api
Nov 18, 2023
4f5d631
Merge branch 'dev/api' of github.com:rit-sse/WebsiteTheSSEquel into d…
Nov 18, 2023
d7cd8ed
return relational IDs with GET requests for course, departments, and …
PokeJofeJr4th Nov 18, 2023
e1474cd
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
PokeJofeJr4th Nov 18, 2023
a557d12
Added jest dependency, refactored mentor in API
joebaillie21 Dec 2, 2023
9d97408
Testing environment created, NOT FUNCTIONAL
joebaillie21 Dec 2, 2023
9edfe0e
Officer routes updated
joebaillie21 Dec 9, 2023
f9f88aa
Added Documentation
joebaillie21 Dec 9, 2023
7bc5b3d
update mentor and department routes
PokeJofeJr4th Jan 28, 2024
bf045a7
update Course API routes
PokeJofeJr4th Jan 28, 2024
7cc1cf2
add user route, update error handling
PokeJofeJr4th Jan 28, 2024
3d76e5d
fix DELETE for user route
PokeJofeJr4th Jan 28, 2024
42f9196
Skills API route finished
grong0 Jan 28, 2024
5f8a44f
Merge remote-tracking branch 'refs/remotes/origin/dev/api' into dev/api
grong0 Jan 28, 2024
9525f64
Removed vulnerabilites with node
grong0 Jan 28, 2024
d865015
update user and mentor error handling
PokeJofeJr4th Feb 3, 2024
440f3ef
added DELETE request for quote API, removed manually-specified id's i…
sjv01180 Feb 3, 2024
a06a439
update golinks api
PokeJofeJr4th Feb 4, 2024
093dffb
Merge branch 'dev/api' of https://github.com/rit-sse/WebsiteTheSSEque…
PokeJofeJr4th Feb 4, 2024
e9345ba
first attempt for postman tests
PokeJofeJr4th Feb 4, 2024
afb1559
update postman tests
PokeJofeJr4th Feb 4, 2024
154856a
Added Update Request for Skills
grong0 Feb 4, 2024
93873ae
Merge remote-tracking branch 'refs/remotes/origin/dev/api' into dev/api
grong0 Feb 4, 2024
1ca048f
try to start API in github workflow
PokeJofeJr4th Feb 4, 2024
73a18f9
try to update API starting
PokeJofeJr4th Feb 4, 2024
42fe423
try to update postman tests
PokeJofeJr4th Feb 4, 2024
d25da37
try to start prisma
PokeJofeJr4th Feb 4, 2024
e4786a3
try to get prisma schema set up
PokeJofeJr4th Feb 4, 2024
6bbba9d
Init commit
grong0 Feb 4, 2024
3db8b36
try to add postgres
PokeJofeJr4th Feb 4, 2024
531881a
Created GET Request
grong0 Feb 4, 2024
4a616c7
try to add prisma database url
PokeJofeJr4th Feb 4, 2024
b8833ce
maybe this will work
PokeJofeJr4th Feb 4, 2024
cb5003b
try to force prisma to do thing
PokeJofeJr4th Feb 4, 2024
5a1dc7b
lets see if this does it 🙃
PokeJofeJr4th Feb 4, 2024
97cccf4
god may judge me but his sins outweigh my own
PokeJofeJr4th Feb 4, 2024
f24a572
;-;
PokeJofeJr4th Feb 4, 2024
6edf16c
:sob:
PokeJofeJr4th Feb 4, 2024
6cec1c8
idk what im doing
PokeJofeJr4th Feb 4, 2024
171913b
maybe this will do it :shrug:
PokeJofeJr4th Feb 4, 2024
e9d7217
mysterious
Feb 4, 2024
3eb3b0e
Created POST Request
grong0 Feb 4, 2024
325b43c
Created PUT Request
grong0 Feb 4, 2024
9db160f
Created DELETE Request
grong0 Feb 4, 2024
74798e2
Created GET with ID request
grong0 Feb 4, 2024
da82311
Updated Skill Route Name
grong0 Feb 4, 2024
9e61dc9
added single get route for quote data
sjv01180 Feb 10, 2024
2a5cb5c
Updated status on course_taken_api.ts
grong0 Feb 10, 2024
7f3c2a9
Created GET request
grong0 Feb 10, 2024
2e3d88b
Created Post Request + Documentation
grong0 Feb 10, 2024
9c9e2ac
Postman Tests - add README.md, move postman tests out of next directory
PokeJofeJr4th Feb 10, 2024
fb6241d
added PUT request to quotes api. Fixed some documentation
sjv01180 Feb 10, 2024
888d8b7
Created PUT Request
grong0 Feb 10, 2024
d0e58bd
add local error section and more tests
PokeJofeJr4th Feb 10, 2024
90f5705
Better names for postman tests
PokeJofeJr4th Feb 10, 2024
a8e769a
Created DELETE Request
grong0 Feb 10, 2024
addd8b9
Merge branch 'dev/postman-tests' into dev/skill-api-routes
grong0 Feb 11, 2024
7c00704
Merge pull request #109 from rit-sse/dev/postman-tests
PokeJofeJr4th Feb 11, 2024
8ebc972
Merge
grong0 Feb 11, 2024
8dd7645
Merge remote-tracking branch 'refs/remotes/origin/dev/api' into dev/api
grong0 Feb 11, 2024
5bd75e6
Merge conficts resolved
grong0 Feb 11, 2024
cacd4d1
add postman tests for golinks
PokeJofeJr4th Feb 11, 2024
8424a32
Conflicts resolved
grong0 Feb 11, 2024
e08850a
Merge remote-tracking branch 'refs/remotes/origin/dev/api' into dev/api
grong0 Feb 11, 2024
1562fea
add route for POST /api/golinks
PokeJofeJr4th Feb 11, 2024
05b71db
update golink tests
PokeJofeJr4th Feb 11, 2024
e656bc4
update golinks api tests again :sob:
PokeJofeJr4th Feb 11, 2024
70fa734
update golinks tests again ;-;
PokeJofeJr4th Feb 11, 2024
66d6332
update golinks API tests (this better be the last time)
PokeJofeJr4th Feb 11, 2024
cb92426
fixed indentation and altered put function of quote api
sjv01180 Feb 17, 2024
c36d683
refactored DELETE function from quote api
sjv01180 Feb 17, 2024
a143d59
assigned self to hourBlock route. kickstart new api
sjv01180 Feb 17, 2024
01dfe89
add schedule API route
PokeJofeJr4th Feb 17, 2024
0350467
add schedule tests
PokeJofeJr4th Feb 17, 2024
45b271e
post request added to hourBlock api. Removed id assignment in seed.ts
sjv01180 Feb 17, 2024
ea8fe87
Merge branch 'dev/api' of github.com:rit-sse/WebsiteTheSSEquel into d…
sjv01180 Feb 17, 2024
684e36c
added delete request and get unique request to hourblocks api. Fixed …
sjv01180 Feb 17, 2024
8724f1a
added PUT request to hourBlocks api
sjv01180 Feb 17, 2024
fc4de70
claiming auth-related api tokens for spike
sjv01180 Feb 17, 2024
e6f9ee7
Merge branch 'main' into dev/api
sjv01180 Feb 17, 2024
cd67136
make seed.ts work with schema changes
PokeJofeJr4th Feb 17, 2024
2a2b4dd
update postman tests and API routes for new schema
PokeJofeJr4th Feb 17, 2024
7f0b550
add package locks to gitignore and delete them
PokeJofeJr4th Feb 17, 2024
b434eee
update gitignores
PokeJofeJr4th Feb 17, 2024
24d0db3
Merge branch 'main' of https://github.com/rit-sse/WebsiteTheSSEquel i…
PokeJofeJr4th Feb 17, 2024
bcd321e
Completed development of skills
grong0 Mar 3, 2024
f7a50d8
Merge remote-tracking branch 'refs/remotes/origin/dev/api' into dev/api
grong0 Mar 3, 2024
c911195
Finished unit tests + added id to get requests
grong0 Mar 3, 2024
2a3b43a
Updated .gitignore
grong0 Mar 23, 2024
3f391d3
Fixed seed data that uses date object to allow testing
grong0 Mar 24, 2024
9485e2e
Finished tests
grong0 Mar 24, 2024
5682728
tests are done
grong0 Apr 7, 2024
6d20b3b
fixed errors in the tests
grong0 Apr 7, 2024
e013987
i reeeeallly hope this fixes the tests
PokeJofeJr4th Apr 14, 2024
e802c8f
i swear to the great flying spaghetti monster in the sky if I have to…
PokeJofeJr4th Apr 14, 2024
917f4c4
Merge branch 'main' into dev/api
PokeJofeJr4th Apr 14, 2024
fe317db
old and stupid Upsilon, and no one comes to visit
PokeJofeJr4th Apr 14, 2024
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
4 changes: 1 addition & 3 deletions .github/workflows/postman-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,4 @@ jobs:
reporters: cli

- name: Output summary to console
if: always()
run: |
echo ${{ steps.run-newman.outputs.summary }}
run: echo ${{ steps.run-newman.outputs.summary }}
10 changes: 9 additions & 1 deletion next/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ next-env.d.ts
# jetbrains
.idea

# nix envs
# jetbrains
.idea

# jetbrains
.idea

# Nix
flake.nix
flake.lock
.envrc
.direnv
2 changes: 0 additions & 2 deletions next/app/api/golinks/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const prisma = new PrismaClient();
function validateGoLink(goLink: string) {
return /^[a-z\-]+$/.test(goLink);
}

/**
* HTTP POST request to /api/golinks
* Create a new Golink
Expand Down Expand Up @@ -32,7 +31,6 @@ export async function POST(request: Request) {
status: 422,
});
}

const newGolink = await prisma.goLinks.create({
data: {
golink: golink,
Expand Down
2 changes: 1 addition & 1 deletion next/app/api/skill/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function GET(request: Request, { params }: { params: { id: string }
id,
},
select: {
id: true,
skill: true,
mentorSkill: {
select: {
Expand All @@ -28,4 +29,3 @@ export async function GET(request: Request, { params }: { params: { id: string }
return new Response("Invalid Skill ID", { status: 400 });
}
}

12 changes: 12 additions & 0 deletions next/app/api/skill/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const prisma = new PrismaClient();
export async function GET() {
const skills = await prisma.skill.findMany({
select: {
id: true,
skill: true,
mentorSkill: {
select: {
Expand Down Expand Up @@ -68,6 +69,17 @@ export async function PUT(request: Request) {
return new Response(`Coulnd't find skill ID ${body.id}`, { status: 404 });
}

if (body.skill != undefined) {
const skill_in_use = await prisma.skill.findUnique({
where: {
skill: body.skill,
},
});
if (skill_in_use != undefined && skill_in_use?.id != body.id) {
return new Response(`skill ${body.skill} already exists`, { status: 422 });
}
}

const skill = await prisma.skill.update({
where: {
id: body.id,
Expand Down
31 changes: 31 additions & 0 deletions next/app/api/skills/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export async function GET(request: Request, { params }: { params: { id: string } }) {
try {
const id = parseInt(params.id);
const skill = await prisma.skill.findUnique({
where: {
id,
},
select: {
skill: true,
mentorSkill: {
select: {
id: true,
mentor_Id: true,
skill_Id: true,
},
},
},
});
if (skill == null) {
return new Response(`Couldn't find Skill ID ${id}`, { status: 404 });
}
return Response.json(skill);
} catch {
return new Response("Invalid Skill ID", { status: 400 });
}
}

88 changes: 88 additions & 0 deletions next/app/api/skills/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export async function GET() {
const skills = await prisma.skill.findMany({
select: {
skill: true,
mentorSkill: {
select: {
id: true,
mentor_Id: true,
skill_Id: true,
},
},
},
});
return Response.json(skills);
}

export async function POST(request: Request) {
let body;
try {
body = await request.json();
} catch {
return new Response("Invalid JSON", { status: 422 });
}

console.log(body);

if (!("skill" in body)) {
return new Response("skill must be included in the body", { status: 400 });
}
const skillName = body.skill;

console.log(`skill name: ${skillName}`);

const skillCount = await prisma.skill.count();

console.log(skillCount);

const skill = await prisma.skill.create({
data: {
id: skillCount+1,
skill: skillName,
},
});

console.log(skill);

return Response.json(skill, { status: 201 });
}

export async function DELETE(request: Request) {
let body;
try {
body = await request.json();
} catch {
return new Response("Invalid JSON", { status: 420 });
}

if (!("id" in body)) {
return new Response("ID must be in body", { status: 400 });
}
const id = body.id;

console.log(id);

const skillExists = await prisma.skill.findUnique({
where: {
id: id,
},
});
if (skillExists == null) {
return new Response(`Coulnd't find skill ID ${id}`, { status: 404 });
}

const _deleteMentorSkills = await prisma.mentorSkill.deleteMany({
where: { skill_Id: id },
});

const skill = await prisma.skill.delete({
where: {
id: id,
},
});
return Response.json(skill);
}
1 change: 1 addition & 0 deletions next/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
nativeBuildInputs = [ pkgs.bashInteractive ];
buildInputs = with pkgs; [
openssl
prisma-engines
nodePackages.prisma
nodePackages.ts-node
];
Expand Down
Loading
Loading