Code Monkey home page Code Monkey logo

node-demo's Introduction

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.

node-demo's People

Contributors

khiemtong avatar alwaysmorehats avatar samuelneff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.