随笔分类 - Node.js
摘要:# 上一篇 [Nest.js + TypeOrm:安装、编写实体类](https://www.cnblogs.com/develon/p/17428854.html) # DataSource.query 进行参数化原始SQL查询 使用 DataSource.query(),注意,如果是 Postg
阅读全文
摘要:# npm proxy ``` $ npm config get proxy http://127.0.0.1:25378/ ``` 如果你的npm设置了如上代理,那么当请求本地服务时,应该会出现代理错误(通常是502响应): ``` import { HttpService } from '@ne
阅读全文
摘要:# 异常过滤器 ## @UseFilters @UseFilters 用于设置异常过滤器,作用于控制器 MethodDecorator & ClassDecorator: ``` import { Controller, UseFilters } from '@nestjs/common'; @Co
阅读全文
摘要:# TypeORM 集成 ``` $ npm install --save @nestjs/typeorm typeorm mysql2/pg ``` 安装过程完成后,我们可以将TypeOrmModule导入到根目录中AppModule。 ```ts import { Module } from '
阅读全文
摘要:# Context isolation and Node integration  ``` Scenario contex
阅读全文
摘要:多进程 HTTP Server import http from 'http'; import cluster from 'cluster'; import { pid, ppid } from 'process'; function server() { let port = 9999; let
阅读全文
摘要:code 由于AsyncLock无法在线程间传递,所以使用事件代替线程,模拟线程间同步: import AsyncLock from 'async-lock'; var lock = new AsyncLock(); function main() { setTimeout(() => task(1
阅读全文
摘要:Atomics Atomics 对象提供了一组静态方法对 SharedArrayBuffer 和 ArrayBuffer 对象进行原子操作。 code import { isMainThread, parentPort, Worker } from 'worker_threads'; functio
阅读全文
摘要:code import * as express from 'express'; import * as http from 'http'; import { WebSocket, WebSocketServer } from 'ws'; const app = express(); const s
阅读全文
摘要:什么是ESM ESM是实验性功能,指Node.js原生支持ES6模块语法的功能。 (node:7736) ExperimentalWarning: The ESM module loader is experimental. 如何使用ESM 创建ESM项目 { "name": "mjs", "ver
阅读全文
摘要:全局安装模块 cnpm without --by=npm 模块将安装在%AppData%\npm\node_modules目录下, 列如: C:\Users\Administrator\AppData\Roaming\npm\node_modules. Ubuntu: /usr/local/lib/
阅读全文
摘要:https HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a separate module. HTTPS是基于TLS/SSL的HTTP协议。在Node.js中,这是作为一个单独的模块实现的。 h
阅读全文
摘要:创建实例 诚然,对于简单的GET和POST请求,只需要设置一个目标URL和对应的HTTP请求体即可: import axios from 'axios'; axios.get('http://192.168.0.150:80/about') .then(response => { console.l
阅读全文
摘要:body-parser 包body-parser属于express,原型如下: [Function] { json: [Getter], // application/json parser raw: [Getter], // application/octet-stream parser text
阅读全文