Welcome to the training!


Course Code: DCL-302
Course Title: NodeJS Programming
Trainer: Dr. Binnur Kurt
Trainer's CV: Curriculum Vitae
Trainer's Blog: http://binkurt.blogspot.com
Research Info: ResearchGate profile
E-mail: binnurkurt@gmail.com


JavaScript is an isomorphic programming language: you can use JS in frontend and backend. This training teaches how to use JavaScript in backend using Node.js.

  • Backend Developers

Module 1 - Scalable Web Architectures

Module 2 - Server-side JS with Node.js

Module 3 - JavaScript

Module 4 - Advanced JavaScript

Module 5 - The evolution of JavaScript

Module 6 - Writing Node Modules

Module 7 - Node Package Manger

Module 8 - MongoDB

Module 9 - Node.js and MongoDB integration

Module 10 - Express.js

Module 11 - Socket-IO

Basic Tools

Description File
Total Commander 9.10 x64 tcmd910x64.exe
7-zip 16.04 (64-bit) 7z1604-x64.msi
Notepad++ 7.5.1 npp.7.5.1.Installer.x64.exe

Development Tools

Description File
Stage for NodeJS Programming DEVEL-stage.nodejs.mongo.webstorm.zip

Lecture Notes

Module No File
Introduction to the training
MODULE 01 Web Architectures
MODULE 02 Server-side JavaScripting with Nodejs
MODULE 03 JavaScript
MODULE 04 Advanced JavaScript
MODULE 05 The Evolution of JavaScript
MODULE 06 Writing Node Modules
MODULE 07 Managing Modules with NPM
MODULE 08 MongoDB
MODULE 09 NodeJS and MongoDB Integration
MODULE 10 Expres.js
MODULE 11 Socket.io

Lab Files

Resource Name File
JSON Files resources.zip
Swagger Open API 2 (HR) swagger-hr.json
Swagger Open API 2 (IMDB) swagger-imdb.json
HR Frontend (KO version) hr-frontend-ko.zip

JS Libraries

Resource Name File
BigNumber Library bignumber.zip

Code Samples

const directorSchema = new mongoose.Schema({
    "_id": mongoose.Schema.Types.ObjectId,
    "name": {
        type: String,
        required: true
    },
    "imdb": {
        type: String,
        required: true,
        validation: /^nm\d+$/
    }
});

const genreSchema = new mongoose.Schema({
    "_id": mongoose.Schema.Types.ObjectId,
    "name": {
        type: String,
        required: true
    }
});

const movieSchema = new mongoose.Schema({
    "_id": mongoose.Schema.Types.ObjectId,
    "title": {
        type: String,
        required: true
    },
    "imdb": {
        type: String,
        required: true,
        validation: /^tt\d+$/
    },
    "year": {
        type: Number,
        default: 2018,
        min: 1920
    },
    "directors": [directorSchema],
    "genres": [genreSchema]
});
function ibanValidator(value) {
	if (value == undefined || value.length < 5) {
        this.throwError("This is not a valid IBAN!")
    }
    modulusResult = this.calculateModulus(value);
    if (modulusResult != 1) {
		return false;
    }
	return true;
}
 
function tcKimlikNoValidator(value) {
	if (value.match("^\\d{11}$")==null) {
       return false;
    }
    digits = new Array(11);
    for (i=0;i<digits.length;++i) {
        digits[i] = value.charCodeAt(i) - 48;
        if (digits[i] < 0 || digits[i] > 9) {
           return false;
        }
    }
    x = digits[0];
    y = digits[1];
    for (i = 1; i < 5; i++) {
        x += Number(digits[2 * i]);
    }
    for (i = 2; i <= 4; i++) {
        y += Number(digits[2 * i - 1]);
    }
    c1 = 7 * x - y;
    if (c1 % 10 != digits[9]) {
       return false;
    }
    c2 = 0;
    for (i = 0; i < 10; ++i) {
        c2 += digits[i];
    }
    if (c2 % 10 != digits[10]) {
       return false;
    }
    return true;
};
const deparmentSchema = new mongoose.Schema({
    "name": {
        type: String,
        required: false,
        enum: ["IT", "Sales", "Finance", "HR"]
    }
});

const employeeSchema = new mongoose.Schema({
    "_id": mongoose.Schema.Types.ObjectId,
    "fullname": {
        type: String,
        required: true,
        minLength: 5
    },
    "identityNo": {
        type: String,
        required: true,
        validate: [tcKimlikNoValidator, 
            "You must provide a valid identity no!"]
    },
    "photo": {
        type: String,
        required: false
        // maxLength: 128000
    },
    "salary": {
        type: Number,
        required: true,
        min: 2000,
        default: 2000
    },
    "iban": {
        type: String,
        required: true,
        validate: [ibanValidator, "You must provide a valid iban!"]
    },
    "department": departmentSchema
}

const Employee = 
    mongoose.model("employees",employeeSchema);
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

Lab Solutions

Useful Links

Subject Link
REST API Documentation Swagger
RAML
APIdocjs
MongoDB İle Çalışmak Read the blog!
JavaScript'de Kısmi Fonksiyon Yazımı Read the blog!
JavaScript'de FilterMapReduce Kullanımı Read the blog!

References

Title Year
JavaScript Patterns 2010
Node.js Design Patterns 2014
Pro Express.js 2014
Node.js in Practice 2014
Express.js Blueprints 2014
Express.js Deep API Reference 2014
RESTful Node.js High Performance 2015
Deploying Node.js 2015
Node.js By Example 2015
RESTful Web API Design with Node.js 2015
Mastering JavaScript Design Patterns 2014