Skip to content

michaelpog/node-demo

 
 

Repository files navigation

Node Demo

Agenda

  1. Setting up
  2. Console Application
  3. Node Web Basics
  4. Making a Web Server
  5. Modules in Node
  6. Restful API in Node
  7. Socket.IO

Setting up

  1. Clone your fork of the repository.
     git clone https://github.com/blinemedical/node-demo.git
     
  2. Open demo directory.
  3. Run npm install with the demo directory.
  4. Run bower install within the demo directory.

Introduce Node

Console Application

Demonstrate how to write a simple console application using Node.

Node Web Basics

Code Example

	var http = require('http');

	var server = http.createServer(function(req, res) {
		//server code
	})

	server.listen(8081);
	console.log('server listening on 8081');

Making a Web Server

	function serveStatic(response, absolutePath)
	{
		fs.exists(absolutePath, function(exists)
		{
			if (!exists)
			{
				send404(response);
				return;
			}

			fs.readFile(absolutePath, function (err, data)
			{
				if (err)
				{
					send404(response);
					return;
				}

				var mimeType = mime.lookup(path.basename(absolutePath));
				response.writeHead(200, {'Content-Type' : mimeType});
				response.end(data);
			});
		});
	}

Modules in Node

  • Demonstrate how to create modules
  • Show how to use modules in different parts of application
  • Each file is its own scope, pass data through exports

Restful API with Database in Node

  • Show how to write a Restful API
  • Demonstrate how to connect to a SQLite database

Socket.IO

  • Cover code sample and how everything is hooked up
  • Show off Socket.IO

Workshop

  • Option 1, enhance existing demos
  • Option 2, build from scratch (a plug.dj clone)
  • Demos at the end of the workshop.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published