express

“[SyntaxError: Unexpected token <]” when I try to add documents to my Solr index with my Node/Express app

强颜欢笑 提交于 2021-02-08 15:11:33
问题 I'm trying to integrate Solr into a Node/Express app and while I am using this Node package for the Solr integration. I am able to properly query the index, but following the instructions on the package's GitHub, I am unable to add documents to the index. I keep getting this error: [SyntaxError: Unexpected token <] On the Solr console, the error is a little more detailed: SEVERE: Error processing "legacy" update command:com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '['

“[SyntaxError: Unexpected token <]” when I try to add documents to my Solr index with my Node/Express app

自古美人都是妖i 提交于 2021-02-08 15:06:43
问题 I'm trying to integrate Solr into a Node/Express app and while I am using this Node package for the Solr integration. I am able to properly query the index, but following the instructions on the package's GitHub, I am unable to add documents to the index. I keep getting this error: [SyntaxError: Unexpected token <] On the Solr console, the error is a little more detailed: SEVERE: Error processing "legacy" update command:com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '['

TypeScript: Extend Express.Session interface with own class

北慕城南 提交于 2021-02-08 15:00:27
问题 I'm working on a Typescript project with npm packages. I want to add a property to the Express.Session interface. example Class: class User { name: string; email: string; password: string; } export = User; New d.ts file for the interface definition (don't want to edit express-session.d.ts): declare namespace Express { interface Session { user: User } } app.ts import User = require('./User'); function (req: express.Request, res: express.Response) { req.session.user //I want to use it like this

Express middleware, next and Promises

对着背影说爱祢 提交于 2021-02-08 13:41:30
问题 There is very simple Express router with handler: router.get('/users/:userId/roles/:roleId', function(req, res, next){ const roleId = req.params.roleId; res.rest.resource = UserModel.findOne({ _id: req.params.userId}).exec().then(function(usr) { console.log(req.params.roleId); // => undefined console.log(roleId); // => okay here const result = usr.roles.find( role => String(role._id) === String(roleId)); return result; }); next(); }); As it seen accessing req.params.roleId within promise

Double request when chrome developer tools open

主宰稳场 提交于 2021-02-08 12:59:33
问题 I've an odd problem, i have a very simple node/expressjs app ( i have a much more complex one but this simple example shows the problem ). This app has three routes as shown here: var i = 0; app.route('/login') .get(function(req, res){ console.log('login', ++i); res.send('login'); }) app.route('/test') .get(function(req, res){ console.log('test', ++i); res.send('test'); }) app.route('/') .get(function(req, res){ console.log('index', ++i); res.send('index'); }) Pretty simple. Any time one of

Typescript: “Cannot find module” with valid typings

你离开我真会死。 提交于 2021-02-08 12:16:30
问题 I just started a new nodejs project using typescript. I installed Typings (https://github.com/typings/typings) and used that to install reference files for node v4.x and express v4.x. My node version is v4.2.6 My typescript version is v1.7.5 My project directory is laid out thus: package.json tsconfig.json typings.json src/ app.ts typings/ main.d.ts main/ambient/node/node.d.ts main/ambient/express/express.d.ts The contents of typings/main.d.ts are as follows: /// <reference path="main/ambient

select columns from right side table in inner join using sequelize

痴心易碎 提交于 2021-02-08 12:09:18
问题 I'm implementing API using Sequelize in node.js. I have three tables i.e. users, projects and userprojects. Here, userprojects table contains foreign key columns i.e. UserId and ProjectId from users and projects table respectively (as shown in picture below) I want to inner join userprojects and projects table so I get final flat result as Project Id (from userproject table) and Project Name (from project table) in a flat format e.g. 7AD60938-60F5-433D-A55B-2F48A9931EFA | Project 01 2582A40C

select columns from right side table in inner join using sequelize

陌路散爱 提交于 2021-02-08 12:07:12
问题 I'm implementing API using Sequelize in node.js. I have three tables i.e. users, projects and userprojects. Here, userprojects table contains foreign key columns i.e. UserId and ProjectId from users and projects table respectively (as shown in picture below) I want to inner join userprojects and projects table so I get final flat result as Project Id (from userproject table) and Project Name (from project table) in a flat format e.g. 7AD60938-60F5-433D-A55B-2F48A9931EFA | Project 01 2582A40C

Ionic 3+ and Node/Express : Http failure response for (unknown url): 0

半世苍凉 提交于 2021-02-08 11:35:54
问题 I've been trying to get data from a local mongodb database, with no success. I've set up a node server using express, cors and mongoose. According to what I've been looking on the internet, this should work : var express = require('express'); var app = express(); var mongoose = require('mongoose'); var cors = require('cors'); app.use(cors({credentials: true, origin: "*", methods: "GET,HEAD,PUT,PATCH,POST,DELETE", preflightContinue:true})); mongoose.connect('mongodb://localhost/cats'); const

Ionic 3+ and Node/Express : Http failure response for (unknown url): 0

放肆的年华 提交于 2021-02-08 11:35:53
问题 I've been trying to get data from a local mongodb database, with no success. I've set up a node server using express, cors and mongoose. According to what I've been looking on the internet, this should work : var express = require('express'); var app = express(); var mongoose = require('mongoose'); var cors = require('cors'); app.use(cors({credentials: true, origin: "*", methods: "GET,HEAD,PUT,PATCH,POST,DELETE", preflightContinue:true})); mongoose.connect('mongodb://localhost/cats'); const