JSDoc correctly document node modules with routes

I am new to writing documentation and wanted to learn how to do it correctly. I have a node REST API that I wish to document. This API consists of a lot of modules that could look like this: /** @module Rewards */ module.exports = function (express, sequelize, router) { router.route(‘/action_plan’); var DataTypes = require(“sequelize”), […]

Is it possible to consume environment variables inside of npm / package.json?

I’m attempting to build a package.json so that when running a NodeJS app on Heroku it will run the scripts.postinstall step using an environment variable. For example: … “scripts”: { “postinstall”: “command $ENV_VAR”} }, … I’ve looked at the docs and wasn’t able to find something saying I can. Is this even possible? Is this […]

Installing gulp to windows 10

I’ve installed gulp npm install –global gulp and set envidoment variable: – variable: GULP_HOME – Value: C:\Users\myaccount\AppData\Roaming\npm\node_modules\gulp (..\gulp is folder) in environment variables And try to run “gulp”. Then i get a message in cmd: C:\myaccount\workspace\todoparrot>gulp [09:47:24] Local gulp not found in C:\myaccount\workspace\todoparrot How to set gulp to work?

Gulp – throw err cannot find module 'q'

I was to trying to setup Jekyll with Gulp but when I run gulp it gives me the following error: C:\Users\Admin\jekyll-gulp-sass-browser-sync-master>gulp module.js:339 throw err; ^ Error: Cannot find module ‘q’ at Function.Module._resolveFilename (module.js:337:15) at Function.Module._load (module.js:287:25) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (C:\Users\Admin\jekyll-gulp-sass-browser-sync-master\node_modules\browser-sync\node_modules\portscanner-plus\lib\index.js:3:9) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at […]

get the max heap size of a node.js application

Now I am using node.js in paas platform. And the container has memory limit. Now I want to get the maximum of the heap size of node.js application. I know that use the parameter “–max-old-space-size”, I can set the max heap size, but I want to know how to get the default value of “–max-old-space-size”. […]

How to use Node tmp Package to write a file from the buffer

I need to write a file temporarily to the file system in order to run a quick check on it, and I then want it deleted. Based on my Googling, it looks like the tmp package for NodeJS can be used: https://www.npmjs.com/package/tmp But I’m really confused by the documentation. This is the example they give […]

WebDriver wait n seconds

I am writing some functional tests with Sauce Labs (Using Selenium + Webdriver + Nodejs). One of my test cases looks like the following: it(‘Should Not Have Any Errors’, function(done) { browser .get(host + ‘/test.live.cgi?view=pixelTest’) .elementById(‘errorHolder’) .text() .should.eventually.equal(‘[]’) .nodeify(done); }); How would I go about waiting 10 seconds between loading the page and checking the […]

Jest with 'npm test' fails with “Use of const in strict mode”

I am just trying to use Jest as unit testing framework. I done and example from official ReactJS side. function sum(value1, value2) { return value1 + value2; } module.exports = sum; —————————————————————- jest.dontMock(‘../sum’); describe(‘sum’, function() { it(‘adds 1 + 2 to equal 3’, function() { var sum = require(‘../sum’); expect(sum(1, 2)).toBe(3); }); }); But when […]

how to forward http request in node js

I want to take the a request, forward it to another url and return the result of the forwared request. This is my code: const http = require(‘http’), server = http.createServer().listen(3000); const baseUrl = ‘foo.bar’; server.on(‘request’, (req, res) => { req.headers.host = baseUrl; var connector = http.request(req, (resp) => { resp.pipe(res); }); req.pipe(connector); }); Sadly, […]

how to integrate swagger with my express application

Always I used to share my node side services to some other teams with proper documentation. Based on this documentation, they will use my services. Regarding this, when I spoke with some other guy. He suggested me to use swagger. But I don’t have any idea how to integrate to my application. My application written […]

Node.js is the Best Javascript runtime in the world.