Skip to content

Commit 14b7e29

Browse files
egg-update
1 parent 527ea42 commit 14b7e29

File tree

19 files changed

+253
-63
lines changed

19 files changed

+253
-63
lines changed

17-nodejs/02-egg/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ coverage/
66
run/
77
logs/
88
.DS_Store
9-
.vscode
109
*.swp
1110
*.lock
1211
*.js
@@ -18,3 +17,5 @@ config/**/*.js
1817
app/**/*.map
1918
test/**/*.map
2019
config/**/*.map
20+
21+
!database/**/*

17-nodejs/02-egg/.vscode/launch.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch Egg",
6+
"type": "node",
7+
"request": "launch",
8+
"cwd": "${workspaceRoot}",
9+
"runtimeExecutable": "npm",
10+
"windows": { "runtimeExecutable": "npm.cmd" },
11+
"runtimeArgs": [ "run", "debug" ],
12+
"console": "integratedTerminal",
13+
"protocol": "auto",
14+
"restart": true,
15+
"port": 9229,
16+
"autoAttachChildProcesses": true
17+
}
18+
]
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"eslint.validate": [
3+
"javascript",
4+
"javascriptreact",
5+
{ "language": "typescript", "autoFix": true },
6+
{ "language": "typescriptreact", "autoFix": true },
7+
]
8+
}

17-nodejs/02-egg/LICENSE

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

17-nodejs/02-egg/README.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# hackernews-async-ts
2-
3-
[Hacker News](https://news.ycombinator.com/) showcase using typescript && egg
1+
# egg-demo-csxiaoyao
42

53
## QuickStart
64

@@ -9,7 +7,7 @@
97
```bash
108
$ npm i
119
$ npm run dev
12-
$ open http://localhost:7001/
10+
$ open http://localhost:2048/
1311
```
1412

1513
Don't tsc compile at development mode, if you had run `tsc` then you need to `npm run clean` before `npm run dev`.
@@ -32,26 +30,31 @@ $ npm start
3230
- Node.js 8.x
3331
- Typescript 2.8+
3432

35-
33+
## Other
34+
Need to start `mysql` & `redis`
35+
```
36+
$ brew services start mysql
3637
$ redis-server
38+
```
39+
40+
## TODO
41+
1. docs
42+
2. whistle & domain
43+
3. login & passport & auth
44+
4. husky
45+
5. lint-staged
46+
6. prettier
47+
48+
## Docs
49+
**validate**
50+
51+
https://github.com/node-modules/parameter#rule
52+
53+
**mocha**
54+
55+
https://mochajs.cn/
56+
57+
**sequelize**
3758

38-
redis
39-
seed
40-
docs
41-
cros
42-
TDD
43-
域名
44-
登录态
45-
权限校验
46-
whistle
47-
husky
48-
lint-staged
49-
prettier
50-
51-
52-
sequelize
5359
https://sequelize.org/master/manual/query-interface.html
5460
https://sequelize.org/master/variable/index.html#static-variable-DataTypes
55-
56-
validate
57-
https://github.com/node-modules/parameter#rule

17-nodejs/02-egg/app/middleware/errorHandler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* 错误处理中间件
3+
*/
14
export default () => {
25
return async function errorHandler(ctx, next) {
36
try {

17-nodejs/02-egg/app/middleware/robot.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
2-
1+
/**
2+
* robot拦截
3+
*/
34
// options === app.config.robot
45
export default (options, app) => {
56
console.log(app.config.robot);

17-nodejs/02-egg/app/model/user.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@ export default function(app: Application) {
3333
app.model.User.hasMany(app.model.Post, { as: 'posts' });
3434
}
3535
};
36-
3736
// return User;
3837
}

17-nodejs/02-egg/app/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default (app: Application) => {
77
router.get('/api/demo', controller.demo.testEnv);
88
router.get('/api/demo/:id', controller.demo.testThrowError);
99
router.post('/api/demo', controller.demo.testRedis);
10-
10+
// restful
1111
router.resources('users', '/api/users', controller.user);
1212
router.resources('posts', '/api/posts', controller.post);
1313
};

17-nodejs/02-egg/config/Code.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
SUCCESS: '0',
3+
TEST_ERROR: '-1', // only for test
4+
CURL_ERROR: '-1000',
5+
DATA_NOT_FOUND: '404',
6+
};

0 commit comments

Comments
 (0)