
Backend
文章平均质量分 64
Javascript, Node.js, Express.js, Spring MVC, ...
KnightHacker2077
CSNOOB
展开
-
Node.js -- CRUD
Create, Read, Update, Delete原创 2022-02-03 06:37:13 · 678 阅读 · 0 评论 -
Express.js -- Request Object
req.paramsReturn route param. The stuff before query param -- '?'Node:router.get('/yomama/:something', function(req, res, next) { console.log(req.params.something);});URI:http://localhost:3000/fibonacci/yomama/3wafwa?node=xxxOutput:3waf原创 2022-02-02 14:23:43 · 339 阅读 · 0 评论 -
Node.js -- http
Create Server调用 http http.createServer(function(req,res){ ... }).listen(portNum); function用于处理client请求并返回response function每次request都会被运行 var http = require('http');var fs = require('fs');var url = require('url'); // 创建服务器http.createServer..原创 2022-01-23 02:34:11 · 86 阅读 · 0 评论 -
Node.js -- GET/POST
GET request解析url -- url.parse e.g.http://localhost:3000/user?name=Charlie var http = require('http');var url = require('url');http.createServer(function(req, res){ // 获取url参数列表 var params = url.parse(req.url, true).query; console.log.原创 2022-01-22 08:14:11 · 200 阅读 · 0 评论 -
Node.js -- File System
fs 同时支持sync & asynce.g. readdirSync vs. readdir获取文件列表fs.readdir(dir_name, function(err,files){})目录名 回调函数 error对象 files数组 fs.readdir('.', function(err,files){ // 读取当前目录文件列表并打印 console.log(files);})获取文件元数据fs.stat(file_p..原创 2022-01-22 04:23:15 · 751 阅读 · 0 评论 -
Node.js -- 全局变量
__filename当前正在执行的脚本的绝对路径__dirname当前执行脚本所在的目录setTimeout(cb, ms)在ms毫秒后执行一次函数(cb)clearTimeout(t)取消Timeout,tsetInterval(cb, ms)每ms毫秒后执行一次函数(cb)clearInterval(cb, ms)取消intervalconsole控制台Process当前进程,一个与操作系统的简单接口...原创 2022-01-21 09:20:13 · 537 阅读 · 0 评论 -
Node.js -- Modules
文件模块一一对应引入模块require用于从外部获取一个模块 引入当前文件夹内的hello.js var hello = require('./hello');导出模块exports用于把对象公开 公开文件中的 'world' function:【hello.js】exports.world = function() {...} 使用world:require('hello'); hello.world() //先import文件,再使用function 直接.原创 2022-01-21 08:51:27 · 108 阅读 · 0 评论 -
Node.js -- Stream
An abstract classthat is widely implemented and used in Node.jsTypes Readable- 可读操作。 Writable- 可写操作。 Duplex- 可读可写操作. Transform- 操作被写入数据,然后读出结果 Stream Events data- 当有数据可读时触发。 end- 没有更多的数据可读时触发。 error- 在接收和写入过程中发生错误时...原创 2022-01-21 08:07:27 · 217 阅读 · 0 评论 -
Node.js -- Buffer
该类用来创建一个专门存放二进制数据的缓存区创建 Buffer 类 const buf1 = Buffer.alloc(10); //创建长度为10的缓存区 写入缓冲区 len = buf.write("www.runoob.com"); //返回实际写入的大小 读取缓存区 buf.toString('utf8') //以utf-8返回字符串 转json buf.toJSON() // 返回 JSON 对象 长度 buf.length; ..原创 2022-01-21 07:48:59 · 218 阅读 · 0 评论 -
Node.js -- Event
Only object in event class: Event.EventEmitter Emitter can both listen and emit eventsMethods原创 2022-01-21 06:54:22 · 218 阅读 · 0 评论 -
Typescript
> npm i typescript> tsc test.ts> node test.jsType Systemany: no type number: double precision (64-bit) floating point null vs. undefined:A variable initialized with undefined means that the variable has no value or object assigned t..原创 2022-01-20 06:53:36 · 340 阅读 · 0 评论 -
Promise
asynchronous programming handle multiple tasks at the same time kip the current operation and move to the next line of the codeSyntaxvar promise = new Promise(function(resolve, reject){// our logic goes here ..});If the function’s response is .原创 2022-01-19 09:30:40 · 83 阅读 · 0 评论 -
Express.js -- Introduction
SetupCreate project folder cd. into the folder and run "npm i -g express-generator" to install project generator globally run "express" to generate project in the project folder option "--view=hbs" sets up the view template run "npm install" instal原创 2022-01-16 05:24:24 · 168 阅读 · 0 评论 -
Node.js -- HTTP
basic es6 classdefinitionclass Note { constructor(key, title, body) { this._key = key; this._title = title; this._body = body; } get key() { return this._key; } get title() { return this._title; } set title(原创 2022-01-15 14:41:42 · 204 阅读 · 0 评论 -
Node.js: CP5
reqreq.url: host名之后的所有内容. e.g. http://localhost:4200/url --> req.url = /url req.method: http method. i.e. GET, POST, PUT DELETEaccessing req body dataNode sends its data using stream API, that is, inchunks.Therefore,the best way to access dat..原创 2022-01-10 05:45:02 · 237 阅读 · 0 评论 -
Javascript: Web
<script>Used to included the javascript code in HTML.Basic format:<script src= "scripts/digital_clock.js"></script>moduleIf you have used modules in your code, i.e. import, export directives, made the script type as module..原创 2022-01-08 02:22:58 · 311 阅读 · 0 评论 -
Javascript 007: Operator
ArityUnary: accepts one single expression. e.g. -x Binary: accepts exactly 2 expressions. e.g. a*b Ternary: combines 3 expressions into 1 expression, only one. i.e. ?: -- conditional operatorlval: 等号左边的variable. e.g. variables, object properties, arra原创 2022-01-07 12:43:21 · 369 阅读 · 0 评论 -
Javascript 006: Expressions
Anexpressionis a phrase of JavaScript that can beevaluatedto produce a value.Primary ExprDoNOTinclude any simpler expressionsconstant orliteralvalues Language keywords (reserved words) Variable referencesConstant and Literals1.23 ...原创 2022-01-03 14:09:33 · 1283 阅读 · 0 评论 -
Javascript 001 -- Generic
Semi-colon -- NOT requiredGarbage Collection (GC) -- Automatic Objected Oriented Comments// /* */Primitive TypesAll rpimitive types are immutablenumbers strings Boolean null undefined symbol (ES6)** Null & undefined have no meth.原创 2021-12-27 14:30:20 · 295 阅读 · 0 评论 -
Javascript 005: Declaration and Assignment
letlet i, sum;Declare and assign an initial value to your variables:let message = "hello";let i = 0, j = 0, k = 0;let x = 2, y = x*x; // Initializers can use previously declared variablesIf you don’t specify an initial value, the value is "un原创 2021-12-29 16:15:04 · 497 阅读 · 0 评论 -
Javascript 004: Type Conversion
ImplicitExplicitUse theBoolean(),Number(), andString()functions Note: toString() is an alternative for String() among most objects other than null or undefined Number()only works for base-10 integers and does not all...原创 2021-12-27 15:38:44 · 281 阅读 · 0 评论 -
Javascript 003: Global Object
A global objectis a javascript object. Its properties defines the globally defined identifiers Created when the Javascript interpreter startsThe default set of propertiesConstants: undefined, Infiity, NaN, etc. Functions: isNan(), parseInt(), eva..原创 2021-12-27 15:19:51 · 273 阅读 · 0 评论 -
Javascript 002: Null & Undefined
"null == undefined" returns true "null ===undefined" returns false Both null and undefined are falsy Both have no properties or methodsNullLanguage keyword typeof("null") = "object" -- i.e. null is actually a genericobject Therefore can be us...原创 2021-12-27 14:59:56 · 354 阅读 · 0 评论 -
Node.js -- npm & packages
核心模块之外,npm & packages link modules together.Common.js package 规范Common.js是JS在后端应用的一个同步规范, 解决了缺乏模块系统、标准库较少、没有标准接口、缺乏包管理系统等问题,让JS成为了一个可以进行大型应用开发的语言Common.js 的包规范即 require**webpack、nodejs、npm 全都是 implement common.js 规范的Package 结构pack..原创 2021-09-11 00:00:36 · 218 阅读 · 0 评论 -
Node & Express 001: Introduction
Express:a “minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.”原创 2021-06-19 16:20:48 · 89 阅读 · 0 评论