-
Notifications
You must be signed in to change notification settings - Fork 30
visit counter endpoint + model, display on homepage #1985
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
base: dev
Are you sure you want to change the base?
Conversation
|
add a screenshot!! |
|
looks good, make sure you fix lint errors, you can run |
| { | ||
| visitCount: { | ||
| type: Number, | ||
| default: 0 | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add one more field, its called type, and it can be an enum like ['HOME_PAGE'] for now
we can then add more stuff to this schema later if we want to track visits to other pages
| const router = express.Router(); | ||
| const visitCounter = require('../models/HomepageVisit'); | ||
| const { FORBIDDEN, BAD_REQUEST, OK } = require('../../util/constants').STATUS_CODES; | ||
| const allowedOrigin = 'https://sce.sjsu.edu'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about if its in dev mode? could we only check if we are in prod?
like if (process.env.NODE_ENV === 'production')
also lets name this variable SCE_SJSU_EDU
| export async function getVisitCount() { | ||
| let status = new ApiResponse(); | ||
| try { | ||
| const res = await fetch (BASE_API_URL + 'api/Homepage/count'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please create and use the url class like below
Clark/src/APIFunctions/User.js
Line 107 in 33fc137
| const res = await fetch(url.href, { |
| export async function incrementVisitCount() { | ||
| let status = new ApiResponse(); | ||
| try { | ||
| await fetch (BASE_API_URL + 'api/Homepage/visit', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see other comment about url class

for issue #1952