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

Backend rewrite #13

Merged
merged 74 commits into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
85b94b2
starting switch to typescript, the any types will kill...
clue4 Oct 20, 2022
30c6ca0
added babel-preset-typescript
Jason0429 Oct 20, 2022
97ecc64
updated package and tsconfig
Jason0429 Oct 21, 2022
da152d6
added outDir to tsconfig
Jason0429 Oct 21, 2022
2c8f038
changed babel-node to ts-node start
Jason0429 Oct 21, 2022
76f79ca
remove @types/graphql due to it being unncessary
clue4 Oct 21, 2022
e94943e
add new @types to dependencies
clue4 Oct 23, 2022
b52d31d
converted models to typescript
jason-palapa Oct 23, 2022
a0638a8
user.ts not yet finished just commiting for now
clue4 Oct 24, 2022
c9bc05c
user.js to user.ts DISCLAIMER did not run db yet
clue4 Oct 26, 2022
02a8c71
add @types/mongoose to packages
clue4 Oct 26, 2022
d7c7a2d
update types in accordance with mongoose typescript guidelines for mo…
clue4 Oct 26, 2022
1c9e742
literally just switched files to ts and they seem fine? require/impor…
clue4 Oct 27, 2022
8e41f3e
whoooo converted another file (literally just renamed it haha)
clue4 Oct 28, 2022
6c35207
sike we're deleting that file
clue4 Oct 28, 2022
52e99b7
deleted uploads file as that is unnecessary
clue4 Oct 30, 2022
56026ba
the smallest of updates, simplified types somehow
clue4 Oct 31, 2022
6ef7cca
i literally have no clue what is going on anymore and i literally do …
clue4 Oct 31, 2022
6ddb5f7
i literally have no clue what is going on anymore and i literally do …
clue4 Oct 31, 2022
d549119
update types for mongoose schemas to be more accurate (we'll need to …
clue4 Nov 1, 2022
46275ae
convert to ts-mongoose
cheungjaso Nov 2, 2022
be46461
converted server.js to server.ts
clue4 Nov 2, 2022
b73b174
Merge branch 'switch-to-ts' of https://github.com/sandboxnu/ScoutTrek…
clue4 Nov 2, 2022
907a402
started conversion to typegoose
Jason0429 Nov 4, 2022
8d5542c
converted models/Event
Jason0429 Nov 4, 2022
6676f48
finished converting models to typegoose
Jason0429 Nov 4, 2022
0fccac1
converting Auth to type-graphql
Jason0429 Nov 5, 2022
7b3b742
removed event fields from user, troop, patrol
Jason0429 Nov 6, 2022
5ce2d56
Get typegoose to work
ross3102 Nov 8, 2022
63030ca
Merge branch 'switch-to-typegoose' into switch-to-ts
ross3102 Nov 8, 2022
abe5f97
Checkin yarn.lock
ross3102 Nov 8, 2022
ed737fb
Remove yarn.lock from gitignore
ross3102 Nov 8, 2022
64efc48
Get backend to work with typegoose and typescript
ross3102 Nov 9, 2022
26f97ae
Change subdocument types
ross3102 Nov 9, 2022
a7e2448
Uncomment code oops
ross3102 Nov 9, 2022
c3f6534
WIP converting User to type-graphql
ross3102 Nov 13, 2022
3411e8b
Get UserResolver to work with queries and combine typegoose and type-…
ross3102 Nov 13, 2022
d7cf610
Convert more models to typegoose and fix auth resolver
ross3102 Nov 14, 2022
a230239
Fix model types
ross3102 Nov 14, 2022
1769e25
Fix age calculation and signup mutation
ross3102 Nov 15, 2022
be25001
Clean up login
ross3102 Nov 15, 2022
b2aea5c
Add typedefs and resolvers for troops and patrols
ross3102 Nov 16, 2022
0c0d9ed
Reorganize code
ross3102 Nov 16, 2022
ecaf29c
Refactor prop to Property for consistency
ross3102 Nov 16, 2022
0788bef
Refactor TODOs
ross3102 Nov 16, 2022
d7b79d7
Fix typegoose middleware, everything works now :)
ross3102 Nov 17, 2022
725220f
Add meetlocation resolver to troop
ross3102 Nov 18, 2022
48c1836
started events but i literally cannot focus it's the allergies
clue4 Nov 20, 2022
cb444c6
added more Event resolvers
Jason0429 Nov 20, 2022
423b728
Added FormTypes
Jason0429 Nov 20, 2022
18aa9ec
field resolvers for event
clue4 Nov 27, 2022
6dae351
event resolver converted
clue4 Nov 28, 2022
29f06d9
fixed up some event resolver errors, still need to more thoroughly te…
clue4 Nov 28, 2022
04bedb5
tried to convert sharedAssets and kinda did but also very unsure what…
clue4 Nov 29, 2022
5131a72
Testing and debugging with frontend, added Jest stuff
ross3102 Nov 30, 2022
3161c5f
Fix authorization error
ross3102 Dec 2, 2022
c825f4d
Fixed token validity check
Jason0429 Dec 2, 2022
e918b27
Add noGroups to login payload
ross3102 Dec 4, 2022
d99cf9d
fix a few bugs and cleanup some code
ross3102 Dec 4, 2022
cd7d05e
Fix tests
ross3102 Dec 4, 2022
df3b72d
Merge branch 'master' into switch-to-type-graphql
ross3102 Dec 4, 2022
3d67eed
use ids safely
ross3102 Dec 4, 2022
7ae4ab0
make typescript a dev dependency only
ross3102 Dec 4, 2022
8757f6b
add missing null check
ross3102 Dec 4, 2022
c2d0e05
updated readme, accidentally on wrong branch
clue4 Dec 4, 2022
9a55ee7
remove unnecessary file
clue4 Dec 4, 2022
9fcc54c
remove unnecessary file, update some comments
clue4 Dec 4, 2022
47f6dcd
rename troop and patrol back to troopID and patrolID
ross3102 Dec 4, 2022
56cbad7
remove unfinished unit tests
ross3102 Dec 4, 2022
01bfe35
make birthday nullable
ross3102 Dec 4, 2022
72f7971
annotate type of age
ross3102 Dec 4, 2022
2fa96e6
make birthday nullable on signup input
ross3102 Dec 4, 2022
2f47c71
set user in ctx even if membership not selected
ross3102 Dec 4, 2022
390b3fe
fix add troop
ross3102 Dec 4, 2022
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
16 changes: 8 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"presets": ["@babel/preset-env"],
"plugins": ["graphql-tag"],
"env": {
"debug": {
"sourceMap": "inline",
"retainLines": true
}
}
"presets": ["@babel/preset-env"],
"plugins": ["graphql-tag"],
"env": {
"debug": {
"sourceMap": "inline",
"retainLines": true
}
}
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ web_modules/

# Optional npm cache directory
.npm
*.lock

# Optional eslint cache
.eslintcache
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

## Tech

* Typescript
* Apollo Server
* Mongoose + Atlas MongoDB Database
* Google Cloud App Engine

Note: Important libraries include type-graphql and typegoose, which help with types for graphql and mongoose respectively


## Setting up on local
1. Clone the repo to your local using `https://github.com/sandboxnu/ScoutTrek-Backend.git`
Expand Down
112 changes: 0 additions & 112 deletions models/Event.js

This file was deleted.

184 changes: 184 additions & 0 deletions models/Event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import { prop as Property } from '@typegoose/typegoose';
import mongoose from 'mongoose';
import { Field, ID, ObjectType, registerEnumType } from 'type-graphql';

import { Roster } from './Roster';
import { Patrol, Troop } from './TroopAndPatrol';
import { User } from './User';

import type { Ref } from "@typegoose/typegoose";
export const DAYS_OF_WEEK = [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
] as const;

export enum EVENT_TYPE {
AQUATIC_EVENT = "AQUATIC_EVENT",
BACKPACK_TRIP = "BACKPACK_TRIP",
BIKE_RIDE = "BIKE_RIDE",
BOARD_OF_REVIEW = "BOARD_OF_REVIEW",
CAMPOUT = "CAMPOUT",
CANOE_TRIP = "CANOE_TRIP",
COMMITTEE_MEETING = "COMMITTEE_MEETING",
CUSTOM_EVENT = "CUSTOM_EVENT",
EAGLE_PROJECT = "EAGLE_PROJECT",
FISHING_TRIP = "FISHING_TRIP",
FLAG_RETIREMENT = "FLAG_RETIREMENT",
FUNDRAISER = "FUNDRAISER",
TROOP_MEETING = "TROOP_MEETING",
HIKE = "HIKE",
KAYAK_TRIP = "KAYAK_TRIP",
MERIT_BADGE_CLASS = "MERIT_BADGE_CLASS",
PARENT_MEETING = "PARENT_MEETING",
SCOUTMASTER_CONFERENCE = "SCOUTMASTER_CONFERENCE",
SERVICE_PROJECT = "SERVICE_PROJECT",
SPECIAL_EVENT = "SPECIAL_EVENT",
SUMMER_CAMP = "SUMMER_CAMP",
SWIM_TEST = "SWIM_TEST",
}

registerEnumType(EVENT_TYPE, {
name: "EventType",
});

export class Point {
@Property({ required: true, enum: ["Point"] as const })
public type!: string;

@Property({ required: true, type: () => [Number] })
public coordinates!: number[];

@Property()
public address?: string;
}

export class MessageUser {
@Property({ required: true })
public name!: string;
}

export class Message {
@Property()
public text?: string;

@Property()
public image?: string;

@Property({ default: Date.now })
public createdAt?: Date;

@Property()
public user?: MessageUser;
}

@ObjectType()
export class Event {
@Field(type => ID, {name: "id"})
readonly _id: mongoose.Types.ObjectId;

@Field(type => EVENT_TYPE)
@Property({ required: true, enum: EVENT_TYPE })
public type!: EVENT_TYPE;

@Field(type => Troop)
@Property({ required: true, ref: () => Troop })
public troop!: Ref<Troop, mongoose.Types.ObjectId>;

@Field(type => Patrol)
@Property({ required: true, ref: () => Patrol })
public patrol!: Ref<Patrol, mongoose.Types.ObjectId>;

@Field()
@Property({ required: [true, "An event cannot have a blank title."] })
public title!: string;

@Field({ nullable: true })
@Property()
public description?: string;

@Field({ nullable: true })
@Property()
public date?: Date;

@Field({ nullable: true })
@Property()
public endDate?: Date;

@Field({ nullable: true })
@Property()
public startTime?: string;

@Field({ nullable: true })
@Property()
public uniqueMeetLocation?: string;

@Field({ nullable: true })
@Property()
public meetTime?: Date;

@Field({ nullable: true })
@Property()
public leaveTime?: Date;

@Field({ nullable: true })
@Property()
public pickupTime?: Date;

@Field({ nullable: true })
@Property()
public endTime?: string;

@Property()
public locationPoint?: Point;

@Property()
public meetLocationPoint?: Point;

@Property({ required: true, type: () => [Message], default: [] })
public messages!: Message[];

@Field(type => Roster)
@Property({ required: true, default: {groups: [], patrols: [], individuals: []} })
public invited!: Roster;

@Field(type => Roster)
@Property({ required: true, default: {groups: [], patrols: [], individuals: []}})
public attending!: Roster;

@Property({ enum: DAYS_OF_WEEK })
public day?: string;

@Field({ nullable: true })
@Property()
public distance?: number;

@Property()
public shakedown?: boolean;

@Property()
public published?: boolean;

@Field(type => User, { nullable: true })
@Property({ ref: () => User })
public creator?: Ref<User, mongoose.Types.ObjectId>;

@Property()
public notification?: Date;

@Field({nullable: true})
createdAt?: string;

@Field({nullable: true})
updatedAt?: string;
}

// type Location {
// lat: Float!
// lng: Float!
// address: String
// }
15 changes: 0 additions & 15 deletions models/Notification.js

This file was deleted.

38 changes: 38 additions & 0 deletions models/Notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { modelOptions, prop as Property } from '@typegoose/typegoose';
import mongoose from 'mongoose';
import { Field, ID, ObjectType } from 'type-graphql';

@modelOptions({
schemaOptions: {
toJSON: { virtuals: true },
toObject: { virtuals: true },
timestamps: true
}
})
@ObjectType()
export class Notification {
@Field(type => ID, {name: "id"})
readonly _id: mongoose.Types.ObjectId;

@Field()
@Property()
public title!: string;

@Field()
@Property()
public type!: string;

@Field()
@Property()
public eventType!: string;

@Field()
@Property()
public eventID!: string;

@Field({nullable: true})
createdAt?: Date;

@Field({nullable: true})
updatedAt?: Date;
}
Loading