create-nserve 1.0.5 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/package.json +1 -1
- package/template/blank/README.md +7 -15
- package/template/blank/src/app.ts +1 -1
- package/template/blank/src/types/index.d.ts +5 -0
- package/template/mysql/README.md +8 -14
- package/template/mysql/package.json +1 -1
- package/template/mysql/src/app.ts +1 -1
- package/template/mysql/src/types/index.d.ts +1 -0
package/README.md
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-nserve 1.0.8
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
🛠️ Description NodeJS Server-side development CLI
|
|
10
|
-
|
|
11
|
-
#### 快速搭建第一个 Nserve 项目
|
|
7
|
+
## 创建项目
|
|
12
8
|
|
|
13
9
|
#### 使用 NPM:
|
|
14
10
|
|
|
@@ -25,5 +21,16 @@ $ yarn create nserve@latest
|
|
|
25
21
|
#### 使用 PNPM:
|
|
26
22
|
|
|
27
23
|
```sh
|
|
28
|
-
$ pnpm create
|
|
24
|
+
$ pnpm create nserve@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
选择 `Blank template` 或 `MySQL ORM`,输入新项目目录名,然后执行:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cd <项目目录>
|
|
31
|
+
npm install
|
|
32
|
+
npm run gen
|
|
33
|
+
npm run dev
|
|
29
34
|
```
|
|
35
|
+
|
|
36
|
+
MySQL 模板还需要先在 `nserve.config.ts` 中填写 `yamlConfig.MYSQL_CONF` 并准备数据库。模板安装的 `@aicblock/nserve` 版本与脚手架版本一致(当前为 1.0.8)。
|
package/package.json
CHANGED
package/template/blank/README.md
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NServe 1.0.8 空白模板
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
#### Description
|
|
8
|
-
|
|
9
|
-
🛠️ Description NodeJS Server-side development CLI
|
|
10
|
-
|
|
11
|
-
#### Installation
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
npm i @aicblock/nserve@latest -g
|
|
15
|
-
# OR
|
|
16
|
-
npm i @aicblock/nserve@latest -D
|
|
3
|
+
```bash
|
|
4
|
+
npm install
|
|
5
|
+
npm run gen
|
|
6
|
+
npm run dev
|
|
17
7
|
```
|
|
8
|
+
|
|
9
|
+
服务默认监听 `http://localhost:3000`,示例接口为 `/api/user/v1/list`,健康检查为 `/api/health`。可在 `nserve.config.ts` 的 `yamlConfig.RUN_PORT` 修改端口;修改路由描述文件后再次运行 `npm run gen`。生产构建使用 `npm run build`。
|
|
@@ -40,7 +40,7 @@ const run = async () => {
|
|
|
40
40
|
message: '接口不存在'
|
|
41
41
|
})
|
|
42
42
|
})
|
|
43
|
-
const RUN_PORT = Number(process.env.RUN_PORT || 3000)
|
|
43
|
+
const RUN_PORT = Number(process.env.RUN_PORT || global.RUN_PORT || 3000)
|
|
44
44
|
// 启动服务器
|
|
45
45
|
app.listen(RUN_PORT, () => {
|
|
46
46
|
console.log(`🚀 服务器运行在端口 ${RUN_PORT}`)
|
package/template/mysql/README.md
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NServe 1.0.8 MySQL 模板
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-

|
|
5
|
-

|
|
3
|
+
先在 `nserve.config.ts` 中填写 `yamlConfig.MYSQL_CONF` 的 `host`、`user`、`password`、`database`(需要时填写 `port`),并准备可连接的 MySQL 数据库。启动时会初始化连接,并根据 `nserve-config/model/*.sql` 创建表。
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
#### Installation
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
npm i @aicblock/nserve@latest -g
|
|
15
|
-
# OR
|
|
16
|
-
npm i @aicblock/nserve@latest -D
|
|
5
|
+
```bash
|
|
6
|
+
npm install
|
|
7
|
+
npm run gen
|
|
8
|
+
npm run dev
|
|
17
9
|
```
|
|
10
|
+
|
|
11
|
+
服务默认监听 `http://localhost:3000`,健康检查为 `/api/health`。可在 `nserve.config.ts` 的 `yamlConfig.RUN_PORT` 修改端口;修改 SQL 或路由描述文件后再次运行 `npm run gen`。生产构建使用 `npm run build`。
|
|
@@ -71,7 +71,7 @@ const run = async () => {
|
|
|
71
71
|
message: '接口不存在'
|
|
72
72
|
})
|
|
73
73
|
})
|
|
74
|
-
const RUN_PORT = Number(process.env.RUN_PORT || 3000)
|
|
74
|
+
const RUN_PORT = Number(process.env.RUN_PORT || global.RUN_PORT || 3000)
|
|
75
75
|
// 启动服务器
|
|
76
76
|
app.listen(RUN_PORT, () => {
|
|
77
77
|
console.log(`🚀 服务器运行在端口 ${RUN_PORT}`)
|