Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wmvm
ts-api-demo
Commits
650e4b53
Commit
650e4b53
authored
Jul 12, 2024
by
wmvm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
a9ed85c0
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
6 deletions
+36
-6
README.md
README.md
+29
-2
index.ts
index.ts
+1
-1
package.json
package.json
+3
-1
test-js-index.js
src/compatible-js/test-js-index.js
+0
-0
user.control.ts
src/functional/mvc/control/user.control.ts
+0
-0
user.service.ts
src/functional/mvc/service/user.service.ts
+0
-1
index.ts
src/functional/router/v1/index.ts
+0
-0
index.ts
src/next/index.ts
+2
-0
tsconfig.json
tsconfig.json
+1
-1
No files found.
README.md
View file @
650e4b53
## 说明
##
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 系列应该都可以启动)

### 方式二
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
index.ts
View file @
650e4b53
...
...
@@ -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
();
...
...
package.json
View file @
650e4b53
...
...
@@ -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"
:
{
...
...
test-js-index.js
→
src/compatible-js/
test-js-index.js
View file @
650e4b53
File moved
src/mvc/control/user.control.ts
→
src/
functional/
mvc/control/user.control.ts
View file @
650e4b53
File moved
src/mvc/service/user.service.ts
→
src/
functional/
mvc/service/user.service.ts
View file @
650e4b53
...
...
@@ -35,4 +35,3 @@ export const getUserInfo = async (payload: UserPayload) => {
user
:
dbUser
}
};
src/router/v1/index.ts
→
src/
functional/
router/v1/index.ts
View file @
650e4b53
File moved
src/next/index.ts
0 → 100644
View file @
650e4b53
// TODO
const
version
=
"next"
\ No newline at end of file
tsconfig.json
View file @
650e4b53
...
...
@@ -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.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment