Create a Node server

Create a file called server.js at the root of the project directory. This will be our node server.

Populate server.js with the following block of code:

// Require dependenciesconst express = require('express');const path = require('path');const http = require('http');const cors = require('cors');const bodyParser = require('body-parser');// Get our API routesconst route = require('./route');const app = express();app.use(bodyParser.json());app.use(bodyParser.urlencoded({ extended: false }));// Use CORSapp.use(cors());// Set our api routesapp.use('/api', route);/*** Get port from environment.*/const port = process.env.PORT || '3000';/*** Create HTTP server.*/const server = http.createServer(app);//Listen on provided port ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.