随笔分类 - Node.js
摘要: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
阅读全文
摘要: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).
阅读全文
摘要:https://btholt.github.io/complete-intro-to-realtime/socketio https://btholt.github.io/complete-intro-to-realtime/intro-to-websockets Socket.io: FE: co
阅读全文
摘要:https://btholt.github.io/complete-intro-to-realtime/intro-to-http2-push long-running HTTP call HTTP2 PUSH FE: async function getNewMsgs() { let reader
阅读全文
摘要:Polling with setTimeout async function getNewMsgs() { let json; try { const res = await fetch("/poll"); json = await res.json(); } catch (e) { // back
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Code: import {UnauthorizedError} from 'express-jwt' function errorMiddleware(error, req, res, next) { if (res.headersSent) { next(error) } else if (er
阅读全文
摘要: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
阅读全文
摘要:import fs from 'fs'; import Jimp = require('jimp'); // filterImageFromURL // helper function to download, filter, and save the filtered image locally
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Features and Modularity In this concept, we dive into splitting our code into logical "features". This is a way of describing modular programming wher
阅读全文
摘要:We have a Netflify serverless functions which requires following packages: "devDependencies": { "playwright-aws-lambda": "^0.4.0", "playwright-core":
阅读全文
摘要:Read Dependency Confusion: How I Hacked Into Apple, Microsoft and Dozens of Other Companies Yarn: yarn install –immutable --immutable-cache --checkcac
阅读全文
摘要:Netlify serverless Set up a Local Development Environment for Serverless Functions Using Netlify Netlify makes developing serverless functions easy wi
阅读全文
摘要:To create a virtual path prefix (where the path does not actually exist in the file system) for files that are served by the express.static function,
阅读全文
摘要:routes/index.js: used for defined all the endpoints: import express from "express"; import * as notes from "./notes.js"; const router = express.Router
阅读全文