- Install Node.js
- Install local package
- Install/uninstall/link/list global package
- Create project
- RESTful API
- Reference
- Install node.js https://nodejs.org/en/
- Install and add to dependencies
npm install --save
- Save the module as a development dependency (Instead of global modules)
npm install --save-dev
- Install for typescript module locally
npm install --save @types/mathjs
- list global package
npm list -g --depth 0
- Instal global
npm install -g package-name
- Remove global
npm uninstall -g package-name
- Use global modules locally (Not Recommanded, Global modules don't be listed as dependencies, even though the project depends on them.)
npm link package-name
-
Create folder
-
Create package.json
npm ini
-
Install for module locally (typescript,express,body-parser,express-session)
npm install --save-dev typescript
npm install --save express
npm install --save body-parser
npm install --save express-session
-
Install types of module locally
npm install --save-dev @types/typescript
npm install --save @types/express
npm install --save @types/body-parser
npm install --save @types/express-session
-
Add tsc Path
D:\data\NodejsProjects\typescript_template\node_modules
-
Create tsconfig.json
tsc –init
-
Configure tsconfig.json and compile by tsc
- Configure tsconfig.json
... "target": "es6", "outDir": "dist", "rootDir": "src", "strict": false ... "include": ["src"], "exclude": []
- Create src folder and delete.ts in src
- Compile .ts into .js
tsc
- Remove delete.ts and dist
- Configure tsconfig.json
Representational State Transfer (REST) is a software architectural style. Web services that conform to the REST architectural style is termed RESTful Web services (RWS).
REST designed Web services whose operations match to particular HTTP methods.
- Operation -> HTTP method
- CREATE -> POST
- READ -> GET
- UPDATE -> PATCH
- DELETE -> DELETE
HTTP Status Codes
- 201 Created
- 404 Not Found
- 200 OK
- 204 No Content