-
Notifications
You must be signed in to change notification settings - Fork 7
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
Daniel t impliment crud for rating #57
base: master
Are you sure you want to change the base?
Conversation
|
||
|
||
const app: Application = express(); | ||
app.use(express.urlencoded({ extended: true })); | ||
app.use(express.json()); | ||
app.use("/" , json({})); | ||
app.use("/api/v1", require('../src/routes/routes')); | ||
app.use("/users/:userID/posts/:postID/rates", routes.rateRouter); | ||
// app.use("/api/v1", require('../src/routes/routes')); |
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.
remove unused routes
@@ -0,0 +1,4 @@ | |||
const Rating = require("../models/rating"); |
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.
the file should be a typescript file. plus you can simply import the module without setting up exporting file.
@@ -0,0 +1,24 @@ | |||
const mongoose = require("mongoose"); | |||
|
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.
add interface definition for the model that extends from mongoose.Doucment, to state the definition of the schema, state the schema definitions and model definition based on this interface
@@ -0,0 +1,13 @@ | |||
const express = require('express') |
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.
use import statements to adhere to es6 importing module pattern
|
||
describe.only('Rating', ()=> { | ||
beforeAll(async () => { | ||
const mongoServer = await MongoMemoryServer.create(); |
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.
use setup.db to open and close in memory server
// starts: expect.any(Number), | ||
// user: expect.any(String) | ||
// })) | ||
}); |
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.
add more testing to the files, simulate what happens when a user rates again, test update rating and other files too.
@@ -0,0 +1,86 @@ | |||
const getOne = (model) => async (req, res) => { |
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.
file should be ts file, plus we don't need other folders, such as utils we can use controllers folder to handle business logics, clone master branch and work on that. plus we don't need crud for rating since its dependent on article you can add your function their.
const ratingController = require('../controllers/rating.controller') | ||
|
||
|
||
router.route('/').get(ratingController.getMany) |
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.
use articles route to handle rating, since they are dependent.
No description provided.