O'Reilly logo

TypeScript: Modern JavaScript Development by Ivo Gabe de Wolff, Vilic Vane, Remo H. Jansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting started with NodeJS

In the previous chapter, we used NodeJS, as gulp uses it. Node can be used for a server and for a command line tool. In this chapter, we will build a server and in Chapter 9, Playing Tic-Tac-Toe against an AI, we will create a command line application. If you haven't installed Node yet, you can download it from nodejs.org.

We will first create a simple server. We will use Phaethon, a package for Node that makes it easy to build a server in NodeJS. Phaethon includes type definitions, so we can use it immediately. We create a file lib/server/index.ts and add the following:

import { Server } from "phaethon"; const server = new Server(); server.listener = request => new phaethon.ServerResponse("Hello"); server.listenHttp(8800); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required