Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BCerki committed Sep 7, 2023
1 parent fba1600 commit 19a371a
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 128 deletions.
7 changes: 0 additions & 7 deletions app/lib/relay/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ const {
} = getConfig();

export function createServerNetwork({ cookieHeader }) {
console.log("--------------------");
console.log("$$$$$$$$cookieHeader", cookieHeader);
// console.log("getCookie", getCookie("qwerty"));
// console.log("getConfig()", getConfig());
console.log("spliting", cookieHeader.split("; ")[1].replace("qwerty=", ""));
console.log("--------------------");
// console.log("SESSION_SECRET", SESSION_SECRET);
return Network.create(async (params, variables) => {
const response = await fetch(`http://localhost:${PORT}/graphql`, {
method: "POST",
Expand Down
4 changes: 0 additions & 4 deletions app/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ app.prepare().then(async () => {
server.use(attachmentDownloadRouter);

server.get("*", async (req, res) => {
// console.log("$$$$$$$$$$$$$$$$$$$$$$res.locals._csrf", res.locals._csrf);
// res.cookie("CSRF-TOKEN", res.locals._csrf);
// console.log("res&&&&", res);

return handle(req, res);
});

Expand Down
112 changes: 1 addition & 111 deletions app/server/middleware/attachmentDeleteRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import config from "../../config";

// export const brianna = (req, res, next) => {
export const attachmentDeleteRouter = Router();
console.log("attachmentDeleteRouter", attachmentDeleteRouter);

const attachmentDetailsQuery = `query AttachmentDetailsQuery($attachmentId: ID!){
attachment(id: $attachmentId) {
Expand Down Expand Up @@ -33,8 +32,6 @@ const deleteAttachmentMutation = `mutation deleteAttachmentMutation($input: Dele
}
`;
const handleDelete = async (req, res, next) => {
console.log("************im in handle delete");
console.log("req.header", req.header);
try {
const attachmentQueryVariables = {
attachmentId: req.params.attachmentId,
Expand All @@ -44,7 +41,7 @@ const handleDelete = async (req, res, next) => {
attachmentQueryVariables,
req
);
console.log("queryResponse", queryResponse);

const {
data: {
attachment: { file, id },
Expand Down Expand Up @@ -77,116 +74,9 @@ const handleDelete = async (req, res, next) => {

const response = await storageClient.bucket(bucketName).file(file).delete();

// res.setHeader("X-CSRF-Token", document.cookie);
console.log("!!!!!!!!!!!response[0].statusCode", response[0].statusCode);
return res.sendStatus(response[0].statusCode);
} catch (error) {
next(error);
}
};
attachmentDeleteRouter.delete("/delete/:attachmentId", handleDelete);

// attachmentDeleteRouter.delete(
// "/delete/:attachmentId",
// () =>
// // {
// // console.log("*********about to handle delete");
// // handleDelete(req, res, next);
// // }
// handleDelete
// );
// next();
// };

// export const brianna = (req, res, next) => {
// const attachmentDeleteRouter = Router();
// console.log("attachmentDeleteRouter", attachmentDeleteRouter);

// const attachmentDetailsQuery = `query AttachmentDetailsQuery($attachmentId: ID!){
// attachment(id: $attachmentId) {
// file
// id
// }
// }`;

// const discardProjectAttachmentFormChangeMutation = `mutation discardProjectAttachmentFormChangeMutation(
// $input: DiscardProjectAttachmentFormChangeInput!
// ) {
// discardProjectAttachmentFormChange(input: $input) {
// formChange {
// id
// }
// }
// }`;

// const deleteAttachmentMutation = `mutation deleteAttachmentMutation($input: DeleteAttachmentInput!) {
// deleteAttachment(input:$input){
// attachment {
// id
// }
// }
// }
// `;
// const handleDelete = async (req, res, next) => {
// console.log("************");
// console.log("req.header", req.header);
// try {
// const attachmentQueryVariables = {
// attachmentId: req.params.attachmentId,
// };
// const queryResponse = await performQuery(
// attachmentDetailsQuery,
// attachmentQueryVariables,
// req
// );

// const {
// data: {
// attachment: { file, id },
// },
// } = queryResponse;
// // delete the form_change related to the attachment
// const attachmentFormChangeResponse = await performQuery(
// discardProjectAttachmentFormChangeMutation,
// req.body.variables,
// req
// );

// // delete the attachment from the attachment table
// const deleteAttachmentResponse = await performQuery(
// deleteAttachmentMutation,
// { input: { id } },
// req
// );

// if (
// queryResponse.errors ||
// attachmentFormChangeResponse.errors ||
// deleteAttachmentResponse.errors
// ) {
// throw new Error(`Failed to delete attachment`);
// }

// const storageClient = new Storage();
// const bucketName = config.get("attachmentsBucket");

// const response = await storageClient
// .bucket(bucketName)
// .file(file)
// .delete();

// // res.setHeader("X-CSRF-Token", document.cookie);
// return res.sendStatus(response[0].statusCode);
// } catch (error) {
// next(error);
// }
// };
// console.log("res.get", res.get("_csrf"));
// console.log("res.getX-CSRF-Token", res.get("X-CSRF-Token"));
// console.log("req.cookie", req.cookies);
// console.log("req.headers", req.headers);
// attachmentDeleteRouter.delete("/delete/:attachmentId", () => {
// console.log("*******************in ");
// return handleDelete(req, res, next);
// });
// };
3 changes: 0 additions & 3 deletions app/server/middleware/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ export async function performQuery(query, variables, request: Request) {
pgSettings: settings,
},
async (context) => {
console.log("**************");
console.log("context", context);
console.log("**************");
// Execute your GraphQL query in this function with the provided
// `context` object, which should NOT be used outside of this
// function.
Expand Down
3 changes: 0 additions & 3 deletions app/server/middleware/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const PgSession = connectPgSimple(expressSession);
// True if the host has been configured to use https
const secure = /^https/.test(config.get("host"));
const secret = config.get("sessionSecret");
console.log("************");
console.log("secret", secret);
console.log("************");

const session = () => {
const store = new PgSession({
Expand Down

0 comments on commit 19a371a

Please sign in to comment.