随笔分类 -  Node.js

上一页 1 2 3 4 5 6 ··· 10 下一页
摘要:server.js: import itemRouter from './resources/item/item.router' export const app = express() app.use('/api/item', itemRouter) item.router.js import { 阅读全文
posted @ 2022-08-22 19:14 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要:Add to global commands Add #! /usr/bin/env node to index.js chmod +x index.js Run ./index.js to test. ln -s <full_path_to_index.js_file>/index.js /usr 阅读全文
posted @ 2022-08-05 21:01 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要:Our CLI can be run from anywhere on the system but we have a critical error. The script is trying to find a data.json file that is relative to where i 阅读全文
posted @ 2022-08-05 20:57 Zhentiw 阅读(84) 评论(0) 推荐(0)
摘要:There are a handful of ways you can read and write to the File System in Node.js. We will look at readFileSync, readFile, and a promise based version 阅读全文
posted @ 2022-08-05 20:25 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要:Node.js projects have two ways that you can import and export code into different files. This is through CommonJS (CJS) and ECMAScript modules (ESM). 阅读全文
posted @ 2022-08-05 19:50 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要:https://btholt.github.io/complete-intro-to-realtime/socketio https://btholt.github.io/complete-intro-to-realtime/intro-to-websockets Socket.io: FE: co 阅读全文
posted @ 2022-07-15 21:27 Zhentiw 阅读(37) 评论(0) 推荐(0)
摘要:https://btholt.github.io/complete-intro-to-realtime/intro-to-http2-push long-running HTTP call HTTP2 PUSH FE: async function getNewMsgs() { let reader 阅读全文
posted @ 2022-07-15 19:43 Zhentiw 阅读(55) 评论(0) 推荐(0)
摘要:Polling with setTimeout async function getNewMsgs() { let json; try { const res = await fetch("/poll"); json = await res.json(); } catch (e) { // back 阅读全文
posted @ 2022-07-15 19:10 Zhentiw 阅读(122) 评论(0) 推荐(0)
摘要:We'll learn how to use Next.js API Routes to hide sensitive information from the clients. In this case, we're calling the JSON Placeholder API with a 阅读全文
posted @ 2022-04-03 17:39 Zhentiw 阅读(60) 评论(0) 推荐(0)
摘要:We'll learn how to create a middleware function for next-connect. This middleware will work at the route level, for example, for every request that hi 阅读全文
posted @ 2022-04-03 17:36 Zhentiw 阅读(123) 评论(0) 推荐(0)
摘要:We'll learn an alternative way of creating API routes using the next-connect package. next-connect gives us an alternative that would feel familiar to 阅读全文
posted @ 2022-04-03 17:34 Zhentiw 阅读(41) 评论(0) 推荐(0)
摘要:Code: import {UnauthorizedError} from 'express-jwt' function errorMiddleware(error, req, res, next) { if (res.headersSent) { next(error) } else if (er 阅读全文
posted @ 2021-08-05 20:58 Zhentiw 阅读(98) 评论(0) 推荐(0)
摘要:When dealing with `fs` library, the common problem you will meet is the path to file. Different envs may have different way to handle the path. The be 阅读全文
posted @ 2021-03-29 14:47 Zhentiw 阅读(50) 评论(0) 推荐(0)
摘要:import fs from 'fs'; import Jimp = require('jimp'); // filterImageFromURL // helper function to download, filter, and save the filtered image locally 阅读全文
posted @ 2021-03-28 01:48 Zhentiw 阅读(150) 评论(0) 推荐(0)
摘要:1. Shell - Linux/Mac Users For Unix/Linux/Mac operating systems, a shell is a command-line program that accepts users' commands and executes those com 阅读全文
posted @ 2021-03-23 01:47 Zhentiw 阅读(134) 评论(0) 推荐(0)
摘要:ORMS allow us to easily switch to a different dialect of SQL (e.g. PostgreSQL, MySQL), without having to modify the code that interacts with the datab 阅读全文
posted @ 2021-03-22 15:33 Zhentiw 阅读(35) 评论(0) 推荐(0)
摘要:Intro to Object-Relational Maps (ORM) We'll be using an ORM called Sequelize to manage the connection to our database. We'll cover the basics in this 阅读全文
posted @ 2021-03-22 15:04 Zhentiw 阅读(32) 评论(0) 推荐(0)
摘要:Features and Modularity In this concept, we dive into splitting our code into logical "features". This is a way of describing modular programming wher 阅读全文
posted @ 2021-03-22 14:48 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要:We have a Netflify serverless functions which requires following packages: "devDependencies": { "playwright-aws-lambda": "^0.4.0", "playwright-core": 阅读全文
posted @ 2021-03-16 20:04 Zhentiw 阅读(79) 评论(0) 推荐(0)
摘要:Read Dependency Confusion: How I Hacked Into Apple, Microsoft and Dozens of Other Companies Yarn: yarn install –immutable --immutable-cache --checkcac 阅读全文
posted @ 2021-02-15 23:27 Zhentiw 阅读(72) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 10 下一页