Browse Source

fixed bug

dev
1549469775 3 years ago
parent
commit
338ed5d7fa
  1. 0
      .env.development
  2. 3
      .env.production
  3. 3
      .gitignore
  4. 2
      docs/a.md
  5. 13
      package.json
  6. 2
      packages/hapi-router/dist/hapi-router.cjs.js
  7. 2
      packages/hapi-router/dist/hapi-router.cjs.js.map
  8. 2
      packages/hapi-router/src/util/index.ts
  9. 1127
      pnpm-lock.yaml
  10. 7
      readme.md
  11. 2
      source/main.ts
  12. 5
      source/route/views/index/index.ts
  13. 5
      source/util/index.ts
  14. 4
      test/index.js
  15. 2
      tsconfig.json

0
.env → .env.development

3
.env.production

@ -0,0 +1,3 @@
NODE_ENV=production
# https://www.bookstack.cn/read/hapijs-zh/2f6997ac6d3fb529.md
KEY = dsRhw1Y5UZqB8SjfClbkrX9PF7yuDMV3JItcW0G4vgpaxONo6mzenHLQET2AiKyPUjjdDko10amjPaba

3
.gitignore

@ -1,4 +1,5 @@
.vscode
.idea
node_modules
log
log
dist

2
docs/a.md

@ -1 +1 @@
sdad
## Hello World

13
package.json

@ -6,9 +6,11 @@
"main": "index.js",
"scripts": {
"init": "ts-node --respawn --project ./tsconfig.json -r tsconfig-paths/register source/db/init.ts alter",
"start": "ts-node-dev --watch ./source/route --ignore-watch ./source/route/route.txt --respawn --project ./tsconfig.json -r tsconfig-paths/register ./source/main.ts",
"dev": "npm start",
"deva": "nodemon --exec 'ts-node --project ./tsconfig.json -r tsconfig-paths/register ./source/main.ts'"
"build": "tsc && tsc-alias",
"start": "node -r dotenv/config dist/main.js dotenv_config_path=.env.production",
"dev": "ts-node-dev --watch ./source/route --ignore-watch ./source/route/route.txt --respawn --project ./tsconfig.json -r tsconfig-paths/register -r dotenv/config ./source/main.ts dotenv_config_path=.env.development",
"deva": "nodemon --exec 'ts-node --project ./tsconfig.json -r tsconfig-paths/register ./source/main.ts'",
"test": "lab --require tsconfig-paths/register --typescript -P test -v"
},
"keywords": [],
"author": "",
@ -31,6 +33,7 @@
"joi": "^17.4.0",
"json-merge-patch": "^1.0.1",
"jsonwebtoken": "^8.5.1",
"jstransformer-markdown-it": "^3.0.0",
"multiparty": "^4.2.2",
"nodemon": "^2.0.7",
"pug": "^3.0.2",
@ -38,12 +41,15 @@
"sqlite3": "^5.0.2"
},
"devDependencies": {
"@hapi/code": "^9.0.1",
"@hapi/lab": "^25.0.1",
"@hapi/vision": "^6.1.0",
"@noderun/hapi-router": "link:packages\\hapi-router",
"@types/fs-extra": "^9.0.13",
"@types/hapi__cookie": "^10.1.4",
"@types/hapi__crumb": "^7.3.3",
"@types/node": "^17.0.21",
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"ejs": "^3.1.6",
"fast-glob": "^3.2.11",
@ -51,6 +57,7 @@
"log4js": "^6.4.1",
"ts-node": "^10.0.0",
"ts-node-dev": "^1.1.6",
"tsc-alias": "^1.7.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.3.2"
}

2
packages/hapi-router/dist/hapi-router.cjs.js

@ -105,7 +105,7 @@ function isIndexEnd(str) {
return str.length == 1 && str.endsWith("/");
}
function walkDir(filePath, exclude) {
if (exclude === void 0) { exclude = ["node_modules", "^_", ".git", ".idea", ".gitignore", "client", "\.txt$"]; }
if (exclude === void 0) { exclude = ["node_modules", "^_", ".git", ".idea", ".gitignore", "client", "\.txt$", "\.test\.js$", "\.test\.ts$"]; }
var files = [];
function Data(opts) {
this.relativeDir = opts.relativeDir;

2
packages/hapi-router/dist/hapi-router.cjs.js.map

File diff suppressed because one or more lines are too long

2
packages/hapi-router/src/util/index.ts

@ -32,7 +32,7 @@ export function isIndexEnd(str:any) {
export function walkDir(
filePath:any,
exclude = ["node_modules", "^_", ".git", ".idea", ".gitignore", "client","\.txt$"]
exclude = ["node_modules", "^_", ".git", ".idea", ".gitignore", "client","\.txt$","\.test\.js$","\.test\.ts$"]
) {
let files:any[] = [];
function Data(opts:any) {

1127
pnpm-lock.yaml

File diff suppressed because it is too large

7
readme.md

@ -5,4 +5,9 @@
* https://blog.meathill.com/tech/fe/interpolation-in-pug-with-extends.html
可参考项目
- https://github.com/hks-epod/paydash
- https://github.com/hks-epod/paydash
增加测试库
- @hapi/code
- @hapi/lab
暂时不太清楚怎么结合使用

2
source/main.ts

@ -1,4 +1,4 @@
require("dotenv").config();
// require("dotenv").config();
import { configure, getLogger } from "log4js";
import log4jsConfig from "./log4js_config";

5
source/route/views/index/index.ts

@ -62,7 +62,10 @@ export default class Index {
// console.log(await glob("docs/"+"*.md"));
const mdPath = path.resolve(baseDir, "docs/"+req.params.path)
if(fs.existsSync(mdPath)){
console.log("哈哈");
const str = fs.readFileSync(mdPath, "utf8")
return h.view("views/css.pug", {
content: str.toString()
});
}
// 解析文档
return h.view("views/css.pug");

5
source/util/index.ts

@ -1,9 +1,12 @@
import path from "path";
export * from "./res-helper";
export const isDev = process.env.NODE_ENV === "development"
export const isProd = process.env.NODE_ENV === "production"
export const baseDir = path.resolve(__dirname, "../../");
export const sourceDir = path.resolve(__dirname, "../../source");
export const sourceDir = isProd? path.resolve(__dirname, "../../dist") : path.resolve(__dirname, "../../source");
export const publicDir = path.resolve(__dirname, "../../public");
export const uploadDir = path.resolve(publicDir, "upload");
export const uploadPath = "/public/upload"; // 图片上传地址

4
test/index.js

@ -1,4 +0,0 @@
const path = require("path")
console.log(path.parse("wallpaper.png"));
console.log(path.format("walll",));

2
tsconfig.json

@ -17,6 +17,6 @@
"#/*": ["types/*"]
}
},
"include": ["source", "types"],
"include": ["source", "types", "test"],
"exclude": ["node_modules"]
}

Loading…
Cancel
Save