Skip to content
New issue

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

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

Already on GitHub? # to your account

Annie/code cleanup and organization #127

Merged
merged 16 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
33 changes: 0 additions & 33 deletions .github/workflows/firebase-hosting-merge.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/firebase-hosting-pull-request.yml

This file was deleted.

69 changes: 0 additions & 69 deletions .github/workflows/heroku-deploy-dev-ts.yml

This file was deleted.

1 change: 1 addition & 0 deletions backend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
rules: {
"prettier/prettier": ["error", { endOfLine: "auto" }],
"class-methods-use-this": 0,
"import/prefer-default-export": "off"
},
ignorePatterns: ["build/*"],
};
1 change: 0 additions & 1 deletion backend/Procfile

This file was deleted.

139 changes: 52 additions & 87 deletions backend/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -1,111 +1,76 @@
import { makeExecutableSchema, gql } from "apollo-server-express";
import { applyMiddleware } from "graphql-middleware";
import { merge } from "lodash";
// import { applyMiddleware } from "graphql-middleware";

import {
typeDefs as scalarTypeDefs,
resolvers as scalarResolvers,
} from "graphql-scalars";

// import { UserType } from "../prisma";
// import {
// isAuthorizedByEmail,
// isAuthorizedByUserType,
// isAuthorizedByUserId,
// } from "../middlewares/auth";
import authResolvers from "./resolvers/authResolvers";
import authType from "./types/authType";
import notificationResolvers from "./resolvers/notificationResolvers";
import notificationType from "./types/notificationType";
import staffResolvers from "./resolvers/staffResolver";
import staffType from "./types/staffType";
import residentResolvers from "./resolvers/residentResolvers";
import residentType from "./types/residentType";
import taskResolvers from "./resolvers/taskResolvers";
import taskType from "./types/taskType";
import warningResolvers from "./resolvers/warningResolvers";
import warningType from "./types/warningType";

const query = gql`
type Query {
_empty: String
}
`;
import dataModels from "./types/models";
import customTypes from "./types/enums";
import resolverTypes from "./types/resolvers";

const mutation = gql`
type Mutation {
_empty: String
}
`;
import participantResolvers from "./resolvers/participantResolver";
import miscResolvers from "./resolvers/miscResolver";

const executableSchema = makeExecutableSchema({
const schema = makeExecutableSchema({
typeDefs: [
...scalarTypeDefs,
query,
mutation,
authType,
notificationType,
staffType,
residentType,
taskType,
warningType,
dataModels,
customTypes,
resolverTypes,
],
resolvers: merge(
scalarResolvers,
authResolvers,
notificationResolvers,
staffResolvers,
residentResolvers,
taskResolvers,
warningResolvers,
participantResolvers,
miscResolvers
),
});

export default schema;

// const authorizedByAllUserTypes = () =>
// isAuthorizedByUserType(new Set([UserType.STAFF, UserType.RESIDENT]));
// const authorizedByStaff = () =>
// isAuthorizedByUserType(new Set([UserType.STAFF]));

const graphQLMiddlewares = {
Query: {
// getNotificationsByUserId: authorizedByAllUserTypes(),
// getNotificationById: authorizedByAllUserTypes(),
// getStaffByIds: authorizedByStaff(),
// getAllStaff: authorizedByStaff(),
// getResidentsByIds: authorizedByStaff(),
// getAllResidents: authorizedByStaff(),
// getActiveResidents: authorizedByStaff(),
// getTaskById: authorizedByAllUserTypes(),
// getTasksByType: authorizedByAllUserTypes(),
// getTasksByAssigneeId: authorizedByAllUserTypes(),
// getTasksByAssignerId: authorizedByStaff(),
// getTasksByStartDate: authorizedByAllUserTypes(),
// getTasksByEndDate: authorizedByAllUserTypes(),
// getTasksByStatus: authorizedByAllUserTypes(),
},
Mutation: {
// login: isAuthorizedByEmail("email"),
// refresh: isAuthorizedByEmail("email"),
// logout: isAuthorizedByUserId("userId"),
// resetPassword: isAuthorizedByEmail("email"),
// sendNotification: authorizedByAllUserTypes(),
// deleteUserNotification: authorizedByStaff(),
// updateSeenNotification: authorizedByAllUserTypes(),
// sendAnnouncement: authorizedByStaff(),
// addStaff: authorizedByStaff(),
// updateStaff: authorizedByStaff(),
// deleteStaff: authorizedByStaff(),
// addResident: authorizedByStaff(),
// updateResident: authorizedByStaff(),
// deleteResident: authorizedByStaff(),
// redeemCredits: authorizedByStaff(),
// createTask: authorizedByAllUserTypes(),
// updateTask: authorizedByAllUserTypes(),
// deleteTask: authorizedByAllUserTypes(),
// assignTask: authorizedByStaff(),
// changeTaskStatus: authorizedByStaff(),
// addWarning: authorizedByStaff(),
// deleteWarning: authorizedByStaff(),
},
};
// const graphQLMiddlewares = {
// Query: {
// // getNotificationsByUserId: authorizedByAllUserTypes(),
// // getNotificationById: authorizedByAllUserTypes(),
// // getStaffByIds: authorizedByStaff(),
// // getAllStaff: authorizedByStaff(),
// // getResidentsByIds: authorizedByStaff(),
// // getAllResidents: authorizedByStaff(),
// // getActiveResidents: authorizedByStaff(),
// // getTaskById: authorizedByAllUserTypes(),
// // getTasksByType: authorizedByAllUserTypes(),
// // getTasksByAssigneeId: authorizedByAllUserTypes(),
// // getTasksByAssignerId: authorizedByStaff(),
// // getTasksByStartDate: authorizedByAllUserTypes(),
// // getTasksByEndDate: authorizedByAllUserTypes(),
// // getTasksByStatus: authorizedByAllUserTypes(),
// },
// Mutation: {
// // sendNotification: authorizedByAllUserTypes(),
// // deleteUserNotification: authorizedByStaff(),
// // updateSeenNotification: authorizedByAllUserTypes(),
// // sendAnnouncement: authorizedByStaff(),
// // addStaff: authorizedByStaff(),
// // updateStaff: authorizedByStaff(),
// // deleteStaff: authorizedByStaff(),
// // addResident: authorizedByStaff(),
// // updateResident: authorizedByStaff(),
// // deleteResident: authorizedByStaff(),
// // redeemCredits: authorizedByStaff(),
// // createTask: authorizedByAllUserTypes(),
// // updateTask: authorizedByAllUserTypes(),
// // deleteTask: authorizedByAllUserTypes(),
// // assignTask: authorizedByStaff(),
// // changeTaskStatus: authorizedByStaff(),
// },
// };

export default applyMiddleware(executableSchema, graphQLMiddlewares);
// export default applyMiddleware(executableSchema, graphQLMiddlewares);
Loading
Loading