NodeJS, express validator working fine in routes, but error when importing from controllers

M

mughil singh

Guest
mughil singh Asks: NodeJS, express validator working fine in routes, but error when importing from controllers
To brief I am new to NodeJS and am trying to make a signup page with backend validation, the tool for the job I am using is express-validator. The validation works fine when I type it into the routes file, however I am trying to split the code into a controller file and I am getting issues, It is telling me that a comma should not be a certain point when I use it in the controller file but when I use it in the routes file it works fine, I know the code is correctly being imported as I also render the page with the same route/controller pair (I have omitted that part of the code for brevity)

SignupRoutes.js

Code:
const express = require('express');
const router = express.Router();

const signupController = require('../controllers/signupController');
router.post('/', signupController.serverSideEmailValidation);

module.exports = router;

signupController.js (Line 6 is the error, the comma at the end of the line)

Code:
const { check, validationResult } = require('express-validator');
const User = require('../models/userModel');
const serverSideEmailValidation = 
check('email')
    .notEmpty().withMessage('Email cannot be empty')
    .isEmail().withMessage('Email is invalid'),
    (req, res) => {

    const errors = validationResult(req);
    if(!errors.isEmpty()){
        return res.status(400).json({errors: errors.array()});

    };
    const user = new User({
        email: req.body.email,
        password: req.body.password
    }); 

    user.save();
    res.redirect('verify-email');
    };

module.exports = {serverSideEmailValidation}

Thanks for your time

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.
 

Unreplied Threads

Can drug metabolites be found in blood tests, or just urine tests?

  • JeanOfGrenoble
  • Biology
  • Replies: 0
JeanOfGrenoble Asks: Can drug metabolites be found in blood tests, or just urine tests?
When doing a blood test, can the metabolites of drugs be detected in it? Or are metabolites only detectable in urine and hair? Can the following drugs or metabolites be found in blood after a month of not taking them?

Interested in these drugs/metabolites

  • Sertraline/Desmethylsertraline
  • Quetiapine/Norquetiapine
  • Abilify/Dehydro-aripiprazole
  • Amitriptyline/nortriptyline
  • Clonazepam/7-aminoclonazepam and similar

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

How to rotate the gridline of a plot?

Javieer Picazo Asks: How to rotate the gridline of a plot?
I'd like to know if it's possible to plot the graph of a function and rotate the xy axis and the gridline without rotating the function itself and any other graphics element you could add such as arrows, points,...

Any suggestions?? I tried to use the command Rotate but it didn't work since I wanted to use Show with it and a vector (arrow) but I got error...

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Reverse mathematics of Banach-Mazur games

Noah Schweber Asks: Reverse mathematics of Banach-Mazur games
Given $\mathcal{A}\subseteq\omega^\omega$, the Banach-Mazur game with payoff set $\mathcal{A}$ consists of players $1$ and $2$ alternately playing nonempty finite strings of naturals with player $1$ winning iff the resulting infinite concatenation is in $\mathcal{A}$. For any bounded level of the projective hierarchy we can formalize this notion in the language of second-order arithmetic to define the sentence $\Sigma^1_n$-$\mathsf{BM}$ for each specific $n\in\omega$. (Here, $\Sigma^1_n$ is used in the boldface sense - that is, set parameters are allowed.)

It is well-known that even $\Sigma^1_2$-$\mathsf{BM}$ is not provable in $\mathsf{ZFC}$. On the other hand, Banach-Mazur determinacy principles are relatively weak on a set-theoretic level: "Every Banach-Mazur game is determined" adds no consistency strength to $\mathsf{ZF+DC}$. So the hierarchy of Banach-Mazur determinacy principles seems like a natural candidate for a set of principles "shooting off to the side" in terms of the well-understood systems of reverse mathematics (namely the big 5 + the higher $\Pi^1_n$-$\mathsf{CA}_0$s).

Question: Over $\mathsf{RCA_0}$, is there any $n$ such that $\Sigma^1_n$-$\mathsf{BM}$ implies $\Pi^1_2$-$\mathsf{CA_0}$?

I strongly suspect that the answer is negative. In fact, I conjecture that no $\Sigma^1_n$-$\mathsf{BM}$ implies $\Pi^1_1$-$\mathsf{CA_0}$. However, I do know that $\mathsf{ATR_0}$ is implied by (hence equivalent to by an old result of Steel) $\Sigma^1_1$-$\mathsf{BM}$, so I suspect that proving this stronger result might be quite hard. By contrast, a non-implication of $\Pi^1_2$-$\mathsf{CA}_0$ seems like it might just take a trick I haven't thought of.

Embarrassing admission: this question comes from a project I started way back in grad school, which despite some results languished largely due to me failing to solve this problem. I've finally given up on solving it myself, ... which on the plus side means that I hope to finish writing up what I do have fairly soon [knocks on wood].

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

On the Menger property and the Alexandroff duplicate

J. Casas Asks: On the Menger property and the Alexandroff duplicate
Recall that a space $X$ is Menger if for each sequence $(\mathcal{U}_n)_{n\in\omega}$ of open covers of $X$, there is a sequence $(\mathcal{V}_n)_{n\in\omega}$ such that, for each $n\in \omega$, $\mathcal{V}_n$ is a finite subcollection of $\mathcal{U}_n$ and $\bigcup\{\mathcal{V}_n:n\in\omega\}$ is an open cover of $X$.

On the other hand, given a space $X$, the Alexandroff duplicate $A(X)$ is defined as follows: The underlying set is $X\times\{0,1\}$, each point of $X\times\{1\}$ is isolated and a basic open neighbourhood for a point $\langle x, 0 \rangle \in X\times\{0\}$ is a set of the form $U\times\{0, 1\}\setminus\{\langle x, 1\rangle\}$ where $U$ is an open neighbourhood of $x$ in $X$.

It turns out that for several topological properties $\mathcal{P}$, it occurs that a space $X$ has the property $\mathcal{P}$ if and only if its Alexandroff duplicate $A(X)$ has the property $\mathcal{P}$. Examples of such properties are compactness, Lindelofness, normality, countably paracompactness, etc. I have found in some papers that, for the Menger property is well-known that this fact also occurs; that is, a space $X$ is Menger if and only if its Alexandroff duplicate $A(X)$ is Menger. The problem is that I have not been able to find a reference where this fact has been showed for the first time. Does anyone knows any reference to be cited where this result had been showed? I agree that showing this fact is not dificult.

Thanks for any help!

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Need help converting deadhead miles to unpaid miles [closed]

Chris Asks: Need help converting deadhead miles to unpaid miles [closed]
I have a complicated math issue I can't figure out. I'm a truck driver, and I get paid a certain rate for my deadhead miles (miles driven empty to a shipper). In my company's spreadsheet, I only have 2 types of miles; Loaded and unloaded.

I prefer deadhead miles in the unloaded section, as deadhead miles are not profitable. That being said, I want to convert the total amount of deadhead miles to a lower number, taking into account the amount of miles that were paid for.

The following is an example:

Total deadhead miles: 505

Rate per mile for deadhead miles: $0.51

Total cost per mile: $0.92

I want an adjusted total miles number, taking out the amount of miles that are paid for with the deadhead RPM. If someone could break down the equation for me, I'd appreciate it. Thanks.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Constructing ordered fields with lattice structure from ordered fields without lattice structure, and vice versa, in constructive mathematics

  • Madeleine Birchfield
  • Mathematics
  • Replies: 0
Madeleine Birchfield Asks: Constructing ordered fields with lattice structure from ordered fields without lattice structure, and vice versa, in constructive mathematics
This post originated from my reference request for the definition of an ordered field in constructive mathematics: Proper definition of ordered field in constructive mathematics

We are working in constructive mathematics. For the sake of this post, let us define a ordered field to be a field $K$ with a strict linear order $<$ such that $0 < 1$ and for all elements $a \in K$ and $b \in K$, if $a > 0$ and $b > 0$ then $a + b > 0$ and $a \cdot b > 0$. $K$ has a partial order $\leq$ defined by $a \leq b := \neg(b < a)$. An ordered field is a lattice field if additionally it contains a binary meet function $\min$ and join function $\max$ such that $(K, \leq, \min, \max)$ is a (unbounded) lattice. A nonlattice field is an ordered field where the partial order $\leq$ does not form a lattice.

In one of the comments of my reference request, Geoffrey Irving states

Given a lattice field, one can adjoin a positive transcendental with no other information to get a nonlattice field. And given a nonlattice field, there is a constructive lattice closure that extends it as a constructive field.

Are there proofs of these two statements?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Inner product is invariant under reflections in the real hyperplane?

James Garrett Asks: Inner product is invariant under reflections in the real hyperplane?
Let $V$ be an (even) finite-dimensional vector space. I’m trying to prove that $$d(r_v(u), r_v(w))=d(u,w),$$ where $d:V \times V \to \mathbb{R}$ is a positive definite symmetric bilinear form (i.e. a real scalar product on $V$, $v$ is a unit vector (that is, that $d(v,v)=1$) and $$r_u(v)=2d(u,v)v-u.$$ Notice that $-r_v$ is the reflection in the real hyperplane orthogonal to $v$. In particular, $r_v^2=1$.

The problem is that when I compute $d(r_v(u),r_v(w))$ I get $$d(r_v(u),2d(v,w)v)+d(2d((v,w)v,-u)+d(u,w)=d(2d(u,v)v,r_v(w)+d(2d(v,w)v,-w)+d(u,w).$$ I fill like I’m close, but, how do I prove that $$d(r_v(u),2d(v,w)v)+d(2d((v,w)v,-u)=0= d(2d(u,v)v,r_v(w)+d(2d(v,w)v,-w)?$$ Any ideas?? :(

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.