Skip to content

Commit 4623877

Browse files
committedNov 17, 2021
update
1 parent 270c667 commit 4623877

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed
 

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Tencent
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# wxcloudrun-express
2+
3+
24
微信云托管 Node.js Express 框架模版,实现简单的计数器读写接口,使用云托管 MySQL 读写、记录计数值。
35

4-
![](https://qcloudimg.tencent-cloud.cn/raw/b2e0019c9391193d0447cd15fea4b25f.png)
6+
![](https://qcloudimg.tencent-cloud.cn/raw/be22992d297d1b9a1a5365e606276781.png)
57

68

79

@@ -100,3 +102,7 @@ curl https://<云托管服务域名>/api/count
100102
```
101103
curl -X POST -H 'content-type: application/json' -d '{"action": "inc"}' https://<云托管服务域名>/api/count
102104
```
105+
106+
## License
107+
108+
[MIT](./LICENSE)

‎index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
const express = require('express')
22
const cors = require('cors')
3+
const morgan = require('morgan')
34
const { init: initDB, Counter } = require('./db')
45

6+
const logger = morgan('tiny')
7+
58
const app = express()
69
app.use(express.urlencoded({ extended: false }))
710
app.use(express.json())
811
app.use(cors())
12+
app.use(logger)
913
// todo: logger
1014

1115
app.get('/', async (req, res) => {
@@ -17,7 +21,9 @@ app.post('/api/count', async (req, res) => {
1721
if (action === 'inc') {
1822
await Counter.create()
1923
} else if (action === 'clear') {
20-
await Counter.xxx()
24+
await Counter.destroy({
25+
truncate: true
26+
})
2127
}
2228
res.send({
2329
code: 0,

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"cors": "^2.8.5",
1313
"express": "^4.16.4",
14+
"morgan": "^1.10.0",
1415
"mysql2": "^2.3.2",
1516
"sequelize": "^6.8.0"
1617
}

0 commit comments

Comments
 (0)