Questions tagged [node.js]
Node.js is an event-based, asynchronous I/O framework that uses Google's V8 JavaScript engine.
499
questions
5
votes
2
answers
16k
views
What is the point of rooms in socket.io?
I was wondering what the purpose of rooms is. See: https://socket.io/docs/rooms-and-namespaces/
You can basically mimic join and leave with just socket.on and socket.off
Take for example:
(no room)
...
1
vote
0
answers
53
views
Node JS Tape Unit Testing : All cases inside one function for a method
I am using tape for unit testing in Node JS. I wanted to ask one thing about better coding while writing unit testing.
When using different inputs to a single method, is it a better idea to use all ...
0
votes
1
answer
135
views
requiring files in nodejs - individual files or group?
When working in NodeJS and requiring custom modules. Is it best practice to require one file that itself requires dependencies, or is it best to explicitly require only the files that are needed?
An ...
-1
votes
1
answer
63
views
node server structure and technologies - support continuous and high volume (amount, not size) data transfare
I'm having trouble planning the structure of my server side workflow and the technologies I should use.
The basic structure and tasks are:
Now, things to consider:
1.the server listens to multiple "...
0
votes
1
answer
416
views
Micro service architecture : Solving complex queries owned by particular service
I am working micro service architecture and figuring out what is the best way to get complex data from a micro service.
So for example : Let's say micro service A is owning data based on any CRUD ...
2
votes
2
answers
253
views
Matching 2 sets of items by price
I'm trying to solve the following problem in the most efficient way I can find.
I want to trade my items for someone elses items, every item have a price and a value.
I want to maximize the value of ...
2
votes
1
answer
2k
views
How to handle UI updates dependent on slow API responses
A side project I'm working on with some friends currently deals with an API interface that, for many reasons, is slow and cannot be changed to improve speed. I'm talking API responses that take ...
1
vote
1
answer
307
views
Split requests between different server applications
I currently have a web server running apache with multiple sites on it using virtual hosts. I want to add a service to my server that is using nodejs but I want it to be accessible under the same ...
3
votes
1
answer
3k
views
Node.js script const variables in SCREAMING_SNAKE_CASE or camelCase
TL/DR: When requiring another script in Node.js and defining it as a const should the variable name still be in camelCase like it was usual with var or should it instead be in SCREAMING_SNAKE_CASE as ...
2
votes
1
answer
399
views
Where should I do integration tests in a multi package project
Background:
I am working on a node project which consists of a core package and several addon packages. For the end product to work, the core package and atleast one of the addon packages should be ...
0
votes
1
answer
206
views
How to serve a computationally intensive application via REST? [closed]
I have got a native image processing application that can enhance photos(peApp). Now, I want to serve this functionality to the world by having a server application that supports REST. Now while ...
0
votes
1
answer
424
views
Best practice to send data to webhooks without multiple redirects
I’m building a payment system for some ebooks with Reactjs on the frontend, Firebase as hosting and database and cloud functions at the backend side. Customers don’t need an account to buy ebooks so ...
0
votes
1
answer
492
views
maintaining indexing on json files
I have a directory which has approx. 100k JSON files.
I want to retrieve a list of file names, where the file satisfies a set of conditions, with a filter condition in same format as we can pass the ...
0
votes
2
answers
119
views
What is the principle that the npm module drydock can provide data at the port when the local web server is already using that port?
When a local web server is already running at port 3000, I wonder why the npm module drydock is able to provide data also through port 3000? I thought once a port is used, then other process cannot ...
0
votes
1
answer
124
views
architecture - relation of scraper and orm classes
Consider the following application structure.
The scraper class extracts the necessary information from a page, and I want to save it to the DB.
The ORM class is a wrapper around sequelize.js. It ...
3
votes
2
answers
902
views
REST API with files as resources?
I'm storing files as REST API resources, sending and receiving them as base64 strings, along with some other metadata. What's the best way to handle GET for the collection? (e.g GET .../api/files)
...
1
vote
1
answer
957
views
Deployment process for deploying nodejs application to production using webpack
I'm trying to work out what the correct process for deploying a nodejs application to a production environment should me, using webpack.
If this was a standard Java/Maven project I might do ...
2
votes
4
answers
443
views
Should exceptions not be thrown in Node.js?
I just started working on a new project and no one throws exceptions over here. I get that you shouldn't be doing that for asynchronous code, but it seems to be a valid way to do things for the ...
1
vote
1
answer
1k
views
Implement a HTTP server on top of NodeJS TCP APIs for learning purposes
I am very interested to learn the HTTP protocol in depth as well as understand the working of NodeJS streams up-close. I figured out that the best way to do this would be to develop an HTTP server in ...
-4
votes
1
answer
3k
views
How does the typescript transpile function work
Assume the following:
/// file.ts
var x = "hello";
x = 1;
console.log(x);
/// file.ts
function transpile(fileName) {
...
}
What steps would typescript take to transpile the file?
How and when ...
0
votes
1
answer
421
views
Should I use mongoose / mongodb to handle my user REST session in nodejs? [closed]
I'm working on a project which has the following development strategy:
Frontend: Angularjs
Backend: NodeJs
DB: Mysql
I'm bulding a REST system with nodejs and I was wondering how should I handle the ...
0
votes
2
answers
63
views
Getting an existing resource in an OOP server API
Background
I've designed and implemented a server app - a stateless REST API that mostly deals with customer CRUD operations.
As it is now the server is designed to use modules for each ...
1
vote
2
answers
1k
views
What risks are there to using Node.js with Java EE?
We are developing a B2B web application in which we are using(suggested by seniors) two servers. One is Node.js (to serve all the request related html & static content) and the other is Tomcat to ...
6
votes
1
answer
4k
views
Microservices Architecture separating backend and front end
We are trying to move (slowly) into Microservices architecture from our current monolithic based architecture. I've done my research on microservices architecture and would like to get some feedback ...
13
votes
4
answers
40k
views
Is it bad design to internally call API endpoints from within the API instance?
For context, I am running a REST API built with Node.js. Because of callbacks and some complex DB calls, I have a chain of functions that are async but also unique, so it's tough to reduce redundancy. ...
1
vote
0
answers
254
views
Best practice to maintain 2 servers - PHP and NodeJs
We have a Symfony backend server for our Android and iOS application. Recently we need to extend our application by supporting real time interaction such as chatting, and we decided to use NodeJs with ...
4
votes
2
answers
2k
views
Realtime frontend dashboard, calling api every 3 seconds, reduce cpu loads
I am working on a networking project. Where I am creating a dashboard to view real time status (CPU/memory usage, up/down traffic and few others) of multiple routers by calling API request to server ...
1
vote
0
answers
53
views
Am I using the right frameworks effectively?
I am working on a large scale application that has both a web portal and a mobile application so therefore I need to develop an API..
I have decided to go with the following structure:-
Sailsjs (...
1
vote
1
answer
931
views
Is this Big Data architecture good enough to handle many requests per second?
I want to ask for a review of my big data app plan. I haven’t much experience in that field, so every single piece of advice would be appreciated.
Here is a link to a diagram of the architecture: My ...
-1
votes
1
answer
332
views
I'm building an app with Node, Express, and MongoDB. Is AngularJS necessary?
Node, Express, and MongoDB are really connected so I can understand why they are frequently used together. For a web app of medium complexity, can I get away with only using HTML/CSS and EJS for the ...
5
votes
2
answers
217
views
Tracking state changes based on duration of time in state
I've been building a monitoring system that checks whether a device is alarmed or not, and if so, sends notifications to relevant users based on how long a device is in a particular state. Here's an ...
1
vote
0
answers
888
views
IPC with Node.js server
I built a post processor for creating CNC machine files to which I'd like to provide a web interface.
Currently the program takes a file path as input and then spits out the results into another file....
0
votes
1
answer
46
views
Creating a better translation for a node.js api to ruby
My client has a nodejs SDK that fetches entries using a client that makes http requests. Their api looks like this:
var Query = Client.ContentType('blog').Query();
Query
.where("title", ...
2
votes
0
answers
555
views
Designing large nanoservice architecture with AWS Lambdas
I'm moving from a coupled architecture to a decoupled architecture using microservices with AWS Lambda.
Here is my current architecture:
Each API Gateway route is linked to a specific Lambda, each ...
4
votes
4
answers
7k
views
Designing a Feed and Notification system in MongoDB
I'm developing a NodeJS API that will be consumed, for now, by an Android app.
I need 2 important things here: a News Feed and a Notification system. And I need it to be scalable.
I'm using ...
1
vote
0
answers
1k
views
It is possible to use a LGPL module on a Electron app licensed as Apache 2.0? [closed]
I'm developing a desktop app (using Node.js and Electron), licensing the code under Apache License v2.0
It's possible to add a module, licensed as Lesser GPL v3, to my app?
I know that compiled ...
3
votes
2
answers
2k
views
What's a good way to deprecate your NPM modules?
One of my NPM modules is, frankly, pretty lame, hasn't been worked on in years, has no watchers, no stars, and only ~50 downloads per month. I'm going to abandon it, and eventually delete it so it ...
1
vote
1
answer
255
views
Howto structure my app.js code to make it easier testable
I have a couple of Philip Hue lights in the hallway. These show the build status on their lights with a small Node.JS application. Its working like a charm.
Currently I am in the process of testing ...
3
votes
2
answers
2k
views
Is it bad practice to generate ids for an object that does not yet exist in the database?
Here is the situation:
There is a Mongo database A and there is Mongo database B.
There is a business concept/Mongo object that is called someModel which exists on one of database B's collections.
...
7
votes
2
answers
153
views
Is repeating an identifier on an API request and response considered a code smell
Is it weird to have an identifier such as (_id) on a request which you send to the API, which "enriches" the request and sends back a response with the same identifier (but obviously more enriched ...
9
votes
2
answers
2k
views
What do you call the layer of modules that call external APIs?
I'm creating a Node app.
I have JavaScript files that include custom functions that make calls to external APIs (in this case Google APIs)
I have JavaScript files in my node app that are related ...
1
vote
0
answers
73
views
designing better and crisp server.js (the file which is called to start node application 'e.g. node server.js')
While creating server.js file we need to provide routes information as
var Login = require('./routes/login.js');
app.use('/login', Login);
Now, suppose the node project is a REST services project. ...
1
vote
2
answers
203
views
Is there any reason to use testing frameworks instead of assert for a lightweight lib of pure functions?
I've just written a simple mathematical library which consists of pure functions that take a few arguments, do some computation and return a result. I'd like to write unit tests for this library, but ...
0
votes
1
answer
675
views
Alternatives for Node.js environment specific code
I recently started to work in a startup that been around for almost 6 years now. Our main code base is in Node.js, which means that it has been used here since the early days and therefore there is a ...
3
votes
1
answer
1k
views
A design pattern that mimics a Flowchart?
I am designing a process of transforming a JSON object to HTML/CSS. It consists of:
Identifying special components
Extracting the special components
Parsing the styles
Parsing the layout etc...
I am ...
2
votes
2
answers
77
views
Encrypting a folder used for serving images?
I have a Node.js application that reads and writes images from a server. The images are stored in a directory on an Ubuntu operating system. Express static routes serve images from that folder when ...
0
votes
1
answer
81
views
How should I balance memory with network latency on a paginated table?
A web application I'm working on has a tool that queries a database and returns up to several thousand rows. When considering pagination, at what point does it make more sense to get the entire result ...
0
votes
0
answers
230
views
Socket.io takes time to load up, what to do while the page is connecting...?
For a real-time forum app I'm working on currently.
It takes about 1-5 seconds for the sockets on my node.js server to connect and deliver the first payload, which is some database results from mongo....
4
votes
1
answer
3k
views
Are Native Promises Still Slower in Node vs Libraries such as Bluebird? [closed]
Does this question still apply: Why are native ES6 promises slower and more memory-intensive than bluebird??
In regards to the latest versions of Node.js and EC7?
1
vote
1
answer
138
views
Is it good to consider elastic search a datastorage?
I am very new to elastic search and i need to know it is even useful to store data?
because i was curious to try my hands on how elastic search works and i used postman>run elastic search then added ...