From a8d96bcd16c479b792ae1618bf1dec51ddfb564e Mon Sep 17 00:00:00 2001 From: u013235949 Date: Fri, 21 Jun 2024 15:08:00 +0800 Subject: [PATCH] Fri Jun 21 15:08:00 CST 2024 inscode --- .inscode | 6 +++++- index.js | 11 ++++++++++- package.json | 12 ++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.inscode b/.inscode index ecc8bdd..e177731 100644 --- a/.inscode +++ b/.inscode @@ -1,6 +1,10 @@ run = "npm i && npm run dev" +language = "node" [env] PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" XDG_CONFIG_HOME = "/root/.config" -npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" \ No newline at end of file +npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" + +[debugger] +program = "main.js" diff --git a/index.js b/index.js index 2d7e683..e98f9cc 100644 --- a/index.js +++ b/index.js @@ -1 +1,10 @@ -console.log("欢迎来到 InsCode"); \ No newline at end of file +const { pathToRegexp, match } = require("path-to-regexp"); + + +console.log("欢迎来到 InsCode"); +// express 的路由匹配使用的 path-to-regexp 库. +// 我们可以在这里测试它的匹配情况. + +// path-to-regexp 中有一个 match 函数. + +const fn = match("/about", { decode: decodeURIComponent }); diff --git a/package.json b/package.json index 72caa17..3c7cbc2 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,15 @@ "description": "", "main": "index.js", "scripts": { - "dev": "node index.js", - "test": "echo \"Error: no test specified\" && exit 1" + "dev": "node index.js", + "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { - "@types/node": "^18.0.6", - "node-fetch": "^3.2.6" + "@types/node": "^18.0.6", + "node-fetch": "^3.2.6", + "path-to-regexp": "^7.0.0" } - } - \ No newline at end of file +} -- GitLab