Istanbul Code coverage – TypeScript with Express on Node js


Needed pacakges: npm install mocha chai istanbul remap-istanbul typescript   Config in package.json : { "name": "express", "version": "0.0.0", "private": true, "scripts": { "start": "node ./dist/www", "build": "tsc -w -p .", "build:ubuntu": "sudo tsc -w -p .", "build:CI": "sudo tsc -p .", "install:global:dependencies": "npm install -g typescript && npm install -g nodemon && npm install … Continue reading Istanbul Code coverage – TypeScript with Express on Node js

Get started with typescript, express and test


At the end of this post, you will have your web app up and running locally in your dev environment. Pre-requisites Before you get started, ensure that you have the following dependencies in place Git Node js NPM Visual Studio Code (or any other editor of your choice) Lets get started Create a new folder … Continue reading Get started with typescript, express and test

Authenticate a Node.js API with JSON Web Tokens


Code #Introduction Authentication is one of the big parts of every application. Security is always something that is changing and evolving. In the past, we have gone over Node authentication using the great Passport npm package. Those articles used the session based authentication however, which has problems when we talk about scaling web services and … Continue reading Authenticate a Node.js API with JSON Web Tokens

Node Js: No ‘Access-Control-Allow-Origin’ header is present on the requested


Add script to file server.js   // Parsers for POST data app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); // Point static path to dist app.use(express.static(path.join(__dirname, 'dist'))); // Add headers app.use(function (req, res, next) { // Website you wish to allow to connect res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4200'); // Request methods you wish to allow res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, … Continue reading Node Js: No ‘Access-Control-Allow-Origin’ header is present on the requested

Append js libraries dynamically to the document in angular 2


ScriptStore.ts that will contain the path of the script either locally or on a remote server and a name that will be used to load the script dynamically interface Scripts { name: string; src: string; } export const ScriptStore: Scripts[] = [ {name: 'filepicker', src: 'https://api.filestackapi.com/filestack.js'}, { name: 'rangeSlider', src: '../../../assets/js/ion.rangeSlider.min.js' } ]; script.service.ts is … Continue reading Append js libraries dynamically to the document in angular 2