Commit 650e4b53 authored by wmvm's avatar wmvm

update

parent a9ed85c0
## 说明
## ts 项目说明
1. dao / common 等基础库和 js 使用同一套,后续基础库都用 ts 重构
2. 业务服务的编码风格暂时保持和 js 风格相同
3. 目前的 ts-dao 和 demo 项目代码风格都是是为了兼容 bibox 和 broker 中大量 js 代码。这样迁移的成本最低
## 启动方式
## demo 项目说明
1. src/compatible-js 是兼容性测试,测试 ts 发布的 dao 可以在 js 项目中正常使用。
2. src/functional 虽然是 ts 代码,但是编程风格延用原有 js 风格的编码方式,理论上把原有 js 代码复制过来基本上可以直接使用
3. src/next 要以一种全新的方式组织代码。
## 本地启动&调试
### 方式一
webstorm 直接启动 (jetBrain 系列应该都可以启动)
......@@ -16,7 +23,27 @@ webstorm 直接启动 (jetBrain 系列应该都可以启动)
![img.png](docs/img2.png)
### 方式二
npm run ts:start:api
### 方式三
全局安装 ts-node
```bash
npm i -g ts-node@10.9.2
ts-node index.ts
```
## 升级 dao 依赖
升级 dao 包的版本时,将版本号手动修改到对应的版本然后执行 npm install
## 生产环境 / 线上部署
npm run build
npm run start:api
......@@ -3,7 +3,7 @@ import errorHandler from 'errorhandler';
import morgan from 'morgan';
import { logger, expressSetting } from '@broker/nodejs_common';
import appConfig from "./config";
import { apiRouterV1 } from "./src/router/v1";
import { apiRouterV1 } from "./src/functional/router/v1";
const app = express();
......
......@@ -4,7 +4,9 @@
"description": "nodejs 代码。 功能:用于合约数据业务层接口。",
"main": "index.ts",
"scripts": {
"build": "rm -rf build && tsc",
"build": "rm -rf build && mkdir -p build && tsc",
"start:api": "node build/index.js",
"ts:start:api": "ts-node index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
......
......@@ -35,4 +35,3 @@ export const getUserInfo = async (payload: UserPayload) => {
user: dbUser
}
};
// TODO
const version = "next"
\ No newline at end of file
......@@ -51,7 +51,7 @@
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
"types": ["mocha","node", "reflect-metadata"], /* Type declaration files to be included in compilation. */
"types": ["node", "reflect-metadata"], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment