Skip to content

Commit 346b7b5

Browse files
committed
added cookie-parser, endpoint functionality tested
1 parent 7c6eae3 commit 346b7b5

File tree

4 files changed

+32
-41
lines changed

4 files changed

+32
-41
lines changed

package-lock.json

Lines changed: 9 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
"socket.io": "^4.6.1",
164164
"socket.io-client": "^4.6.1",
165165
"source-map-support": "^0.5.21",
166-
"typescript-coverage-report": "^0.7.0",
167166
"ts-node": "^10.9.1",
167+
"typescript-coverage-report": "^0.7.0",
168168
"uniqid": "^5.4.0",
169169
"use-debounce": "^8.0.3",
170170
"uuid": "^8.3.2"

server/controllers/marketplaceController.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const marketplaceController: MarketplaceController = {
3333
publishProject: (req, res, next) => {
3434
const { _id, project, comments, userId, username, name } = req.body;
3535
const createdAt = Date.now();
36-
3736
if (userId === req.cookies.ssid) {
37+
console.log('inside');
3838
Projects.findOneAndUpdate(
3939
// looks in projects collection for project by Mongo id
4040
{ _id },
@@ -58,13 +58,15 @@ const marketplaceController: MarketplaceController = {
5858
}
5959
);
6060
}
61-
// we should not expect a user to be able to access another user's id, but included error handling for unexpected errors
62-
return next({
63-
log: 'Error in marketplaceController.publishProject',
64-
message: {
65-
err: 'Error in marketplaceController.publishProject, check server logs for details'
66-
}
67-
})
61+
else {
62+
// we should not expect a user to be able to access another user's id, but included error handling for unexpected errors
63+
return next({
64+
log: 'Error in marketplaceController.publishProject',
65+
message: {
66+
err: 'Error in marketplaceController.publishProject, check server logs for details'
67+
}
68+
})
69+
}
6870
},
6971

7072
/**
@@ -91,13 +93,16 @@ const marketplaceController: MarketplaceController = {
9193
return next();
9294
});
9395
}
94-
// we should not expect a user to be able to access another user's id, but included error handling for unexpected errors
95-
return next({
96-
log: `Error in marketplaceController.unpublishProject`,
97-
message: {
98-
err: 'Error in marketplaceController.unpublishProject, userId of project does not match cookies.ssid'
99-
}
100-
})
96+
else {
97+
// we should not expect a user to be able to access another user's id, but included error handling for unexpected errors
98+
return next({
99+
log: `Error in marketplaceController.unpublishProject`,
100+
message: {
101+
err: 'Error in marketplaceController.unpublishProject, userId of project does not match cookies.ssid'
102+
}
103+
})
104+
105+
}
101106
}
102107
};
103108
export default marketplaceController;

server/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { json, urlencoded } = bodyParser;
1010
const { makeExecutableSchema } = require('@graphql-tools/schema');
1111

1212
import express from 'express';
13-
// import cookieParser from 'cookie-parser';
13+
import cookieParser from 'cookie-parser';
1414

1515
import config from '../config.js';
1616
const { API_BASE_URL, DEV_PORT } = config;
@@ -41,7 +41,7 @@ const isTest = process.env.NODE_ENV === 'test';
4141

4242
app.use(express.json({ limit: '100mb' }));
4343
app.use(express.urlencoded({ limit: '100mb', extended: true }));
44-
44+
app.use(cookieParser());//added cookie parser
4545
// Routes
4646
// const stylesRouter = require('./routers/stylesRouter');
4747
import stylesRouter from './routers/stylesRouter';

0 commit comments

Comments
 (0)