Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

danielteferadeti
Copy link
Member

No description provided.



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'));
Copy link
Collaborator

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");
Copy link
Collaborator

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");

Copy link
Collaborator

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')
Copy link
Collaborator

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();
Copy link
Collaborator

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)
// }))
});
Copy link
Collaborator

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) => {
Copy link
Collaborator

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)
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants