{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210 {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Calibri;\f2\fnil\fcharset0 Consolas; \f3\fnil\fcharset0 Menlo-Regular;\f4\fnil\fcharset0 Menlo-Italic;\f5\fnil\fcharset0 Menlo-Bold; \f6\fnil\fcharset0 Menlo-BoldItalic;} {\colortbl;\red255\green255\blue255;\red0\green45\blue153;\red38\green38\blue38;\red245\green245\blue245; \red14\green114\blue164;\red148\green6\blue75;\red213\green58\blue6;\red56\green110\blue255;\red77\green77\blue77; \red128\green128\blue128;\red0\green0\blue128;\red102\green14\blue122;\red0\green128\blue0;\red122\green122\blue67; \red69\green131\blue131;} \paperw12240\paperh15840\margl1440\margr1440\vieww23060\viewh12620\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \f0\fs24 \cf0 1. Install HomeBrew (brew) Mac OS X package manager:\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf2 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \b0 \cf0 \ \ 2. Install Node.js via brew:\ \ \b \cf2 brew install node \b0 \cf0 \ \ Node comes with npm - program and dependency installation tool. But we need to upgrade it as it\'92s updated more frequently than node:\ \ \b \cf2 npm install npm -g \b0 \cf0 // arba per sudo\ \ 4. Install TypeScript dependency module. Pastaba: typescript\'92a instaliuojame globaliai, nes ts failai yra kompiliuojami i js, kuriuos ir deployinsime.\ \ \b \cf2 npm install typescript -g \b0 \cf0 \ \ Ps. you can check TypeScript version with the command: \f1\fs28 \expnd0\expndtw0\kerning0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf2 tsc -v \f0\b0\fs24 \cf0 \kerning1\expnd0\expndtw0 \ \ PS2. Jeigu raso, kad npm command not found padaryti clean reinstall (https://gist.github.com/DanHerbert/9520689):\ \ \pard\pardeftab720 \f2\fs28 \cf3 \cb4 \expnd0\expndtw0\kerning0 rm -rf /usr/local/lib/node_modules\ brew uninstall node\ brew install node --without-npm\ \pard\pardeftab720 \cf5 \expnd0\expndtw0\kerning0 echo\cf3 \expnd0\expndtw0\kerning0 prefix=\cf6 \expnd0\expndtw0\kerning0 ~\cf3 \expnd0\expndtw0\kerning0 /.node \cf6 \expnd0\expndtw0\kerning0 >>\cf3 \expnd0\expndtw0\kerning0 \cf6 \expnd0\expndtw0\kerning0 ~\cf3 \expnd0\expndtw0\kerning0 /.npmrc\ curl -L https://www.npmjs.com/install.sh \cf6 \expnd0\expndtw0\kerning0 |\cf3 \expnd0\expndtw0\kerning0 sh\ \ \cf6 \expnd0\expndtw0\kerning0 export\cf3 \expnd0\expndtw0\kerning0 PATH=\cf7 \expnd0\expndtw0\kerning0 "\cf3 \expnd0\expndtw0\kerning0 $HOME\cf7 \expnd0\expndtw0\kerning0 /.node/bin:\cf3 \expnd0\expndtw0\kerning0 $PATH\cf7 \expnd0\expndtw0\kerning0 "\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \f0\fs24 \cf0 \cb1 \kerning1\expnd0\expndtw0 Dabar instaliuojam typescript...\ \ 5. Make sure \'93java -version\'94 shows you java 1.7+ installed. If not then install newest java JDK (Not JRE):\ \ http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html\ \ \pard\pardeftab720 \f1\fs28 \cf0 \expnd0\expndtw0\kerning0 6. Download Eclipse for PHP development 64 bit\ \ 7. Instal nodeEclipse plugin:\'a0{\field{\*\fldinst{HYPERLINK "http://www.nodeclipse.org/updates"}}{\fldrslt \cf8 \expnd0\expndtw0\kerning0 \ul \ulc8 http://www.nodeclipse.org/updates}}/ (drag install icon to Eclipse Menu area)\ \ 8. Install typescript plugin: https://github.com/palantir/eclipse-typescript\ \ 9. Eclipse ant project spaudziant desini peles, tada properties. Pasirenkame Resource FIlters. Pridedame i exclude *.js failus, *.js.map failus (rekursyviai) ir node_modules direktorija.\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \f0\fs24 \cf0 \kerning1\expnd0\expndtw0 10. Deployment script:\ \ http://superuser.com/questions/299938/how-can-i-recursively-copy-files-by-file-extension-preserving-directory-structu\ \ cd /Users/gytenis/data/AmazonWoods/Projects/Auth/\ find . -name '*.js' -o -name '*.json' | cpio -pdm '/Users/gytenis/data/AmazonWoods/Projects/AuthDeploy';\ \ \ 11. TypeScript kompiliatoriaus comandos (tsc) parametras, nurodantis kompiliavimo tipa\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf2 --module CommonJS \b0 \cf0 \ \ Pastaba2: galima padaryti, kad viskas butu kompiliuojama i viena faila:\ \ --out ServerMain.js\ \ \'97\'97\ \ 12. Sukuriam package.json konfiguravimo faila. Naudojamas kaip project description ir dependencies aprasymui. \ \ \b \cf2 npm init \b0 \cf0 \ \ 13. Install hapi framework (and add its reference to package.json):\ \ \pard\pardeftab720 \b \cf2 npm install --save hapi \b0 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \cf0 \ \ 14. Paleidziam node serva is direktorijos:\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f3\fs22 \cf0 \CocoaLigature0 node server.js \f0\fs24 \CocoaLigature1 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf0 \'97\'97\'97 Esmines komandos \'97\'97 \b0 \ \ \ \b 1. Dependecy (package) local install \b0 : https://docs.npmjs.com/getting-started/installing-npm-packages-locally\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf2 npm install <libo pavadinimas> --save \i\b0 \cf9 // save parametras dar papildomai iraso dependency pavadinima i package.json faila \i0 \cf0 \ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf0 PS \b0 . \b Global install \b0 : automatiniams taskams (pvz. naudojant Grunt), tam tikrus paketus reikia installinti globaliai: https://docs.npmjs.com/getting-started/installing-npm-packages-globally\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf2 npm install -g <libo pavadinimas> \b0 \cf0 \ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf0 2. Dependecy remove: \b0 https://docs.npmjs.com/cli/uninstall\ \ \b 3. Including Classes and Interfaces. \b0 When you define a class or interface in the separate file as type (and of course you want to be able to include that in other files) then at the end you need to add\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f4\i \cf10 // Creating interface and class \f0\i0 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f5\b \cf11 interface \f3\b0 \cf0 UserInterface \{\uc0\u8232 \u8232 \f5\b \cf12 email \f3\b0 \cf0 : \f5\b \cf11 string \f3\b0 \cf0 ;\uc0\u8232 \}\u8232 \u8232 \f5\b \cf11 class \f3\b0 \cf0 UserObject \f5\b \cf11 implements \f3\b0 \cf0 UserInterface \{\uc0\u8232 \u8232 \f5\b \cf11 public\uc0\u8232 \u8232 \f3\b0 \cf0 \f5\b \cf12 email \f3\b0 \cf0 : \f5\b \cf11 string \f3\b0 \cf0 ;\uc0\u8232 \u8232 \u8232 \f5\b \cf12 private\uc0\u8232 \u8232 \f4\i\b0 \cf10 // ...\uc0\u8232 \f3\i0 \cf0 \}\uc0\u8232 \u8232 \f5\b \cf11 export \f3\b0 \cf0 = UserObject; \f4\i \cf10 // This will allow to import and use UserObject class inside other files. If we want to be able to use interface then we need to export it also.\ \ // Importing and using this class inside other file - UserModel. Please note, the first line is used for TypeScript compiler. We will need to include this file in many files, therefore maybe it would be convenient to auto insert when new file is created.\ \f3\i0 \cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f4\i \cf10 /// <reference path="../node.d.ts" />\uc0\u8232 \u8232 \f5\i0\b \cf11 import \f3\b0 \cf0 UserObject = \f5\b \cf11 require \f3\b0 \cf0 ( \f5\b \cf13 '../DataObjects/UserObject' \f3\b0 \cf0 ); \f4\i \cf10 // This will include class signature \f3\i0 \cf0 \uc0\u8232 \u8232 \f5\b \cf11 class \f3\b0 \cf0 UserModel \{\uc0\u8232 \u8232 \f5\b \cf11 public\uc0\u8232 \u8232 \f3\b0 \cf14 getUserDetails\cf0 () : \f5\b \cf11 string \f3\b0 \cf0 \{\uc0\u8232 \u8232 \f5\b \cf11 var \f3\b0 \cf15 userJsonString \cf0 = \f5\b \cf13 '\{"firstName" : "Gytenis", "lastName" : "Mikulenas"\}' \f3\b0 \cf0 ;\uc0\u8232 \f5\b \cf11 var \f3\b0 \cf15 user \cf0 = \f5\b \cf11 new \f3\b0 \cf0 UserObject(\cf15 userJsonString\cf0 );\uc0\u8232 \u8232 \f5\b \cf11 return \f3\b0 \cf15 user\cf0 .\cf14 fullname\cf0 ();\uc0\u8232 \}\u8232 \}\u8232 \u8232 \f5\b \cf11 export \f3\b0 \cf0 = UserModel; \f4\i \cf10 // Making UserModel class available to include in other files \f3\i0 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \f0 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \b \cf0 4. Including objects (functions, arrays and etc) in other files \b0 . Routes are grouped and defined as arrays of anonymous objects. However, each route group is stored in separate file. In order to be able to use those route arrays in other files, we need to use a slightly different approach:\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f4\i \cf10 // This is an example of UserRoute where we define two anonymous objects-routes for handling related requests. Please note we use module.exports instead (see at the end) \f0\i0 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f4\i \cf10 /// <reference path="../node.d.ts" />\uc0\u8232 \u8232 \f5\i0\b \cf11 import \f3\b0 \cf0 UserModel = \f5\b \cf11 require \f3\b0 \cf0 ( \f5\b \cf13 '../Models/UserModel' \f3\b0 \cf0 );\uc0\u8232 \u8232 \f5\b \cf11 var \f6\i \cf12 userModel \f3\i0\b0 \cf0 = \f5\b \cf11 new \f3\b0 \cf0 UserModel;\uc0\u8232 \u8232 \f6\i\b \cf12 module \f3\i0\b0 \cf0 . \f5\b \cf12 exports \f3\b0 \cf0 = [\uc0\u8232 \u8232 \{ \f5\b \cf12 method \f3\b0 \cf0 : \f5\b \cf13 'GET' \f3\b0 \cf0 , \f5\b \cf12 path \f3\b0 \cf0 : \f5\b \cf13 '/users' \f3\b0 \cf0 , \cf14 handler\cf0 : \f5\b \cf11 function \f3\b0 \cf0 (request, reply) \{ reply( \f6\i\b \cf12 userModel \f3\i0\b0 \cf0 .\cf14 getUserDetails\cf0 ()); \} \},\uc0\u8232 \{ \f5\b \cf12 method \f3\b0 \cf0 : \f5\b \cf13 'GET' \f3\b0 \cf0 , \f5\b \cf12 path \f3\b0 \cf0 : \f5\b \cf13 '/users/\{id\}' \f3\b0 \cf0 , \cf14 handler\cf0 : \f5\b \cf11 function \f3\b0 \cf0 (request, reply) \{\} \}\uc0\u8232 ];\ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \f0 \cf0 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f4\i \cf10 // In order to use this array inside another file, we need to use var instead of import \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f5\i0\b \cf11 var \f6\i \cf12 userRoute \f3\i0\b0 \cf0 = \f4\i \cf11 require \f3\i0 \cf0 ( \f5\b \cf13 './UserRoute' \f3\b0 \cf0 );\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural \cf0 \ \ \ \ \ }