-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wmui
committed
Jul 4, 2023
1 parent
e799c8b
commit acede19
Showing
122 changed files
with
4,405 additions
and
3,975 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +0,0 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
# Vue 3 + Vite | ||
# platform | ||
|
||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more. | ||
|
||
## Recommended IDE Setup | ||
|
||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) | ||
|
||
### TODO | ||
|
||
1. 为什么icon组件在jsx中不用注册可以直接使用 | ||
2. Modal的icon属性,直接使用图标组件实现原理 | ||
开发中 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/*.d.ts | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "eslint-config-egg/typescript" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
logs/ | ||
npm-debug.log | ||
node_modules/ | ||
coverage/ | ||
.idea/ | ||
run/ | ||
logs/ | ||
.DS_Store | ||
.vscode | ||
*.swp | ||
*.lock | ||
*.js | ||
.eslintcache | ||
|
||
app/**/*.js | ||
test/**/*.js | ||
config/**/*.js | ||
app/**/*.map | ||
test/**/*.map | ||
config/**/*.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# hackernews-tegg | ||
|
||
[Hacker News](https://news.ycombinator.com/) showcase using [tegg](https://github.com/eggjs/tegg) | ||
|
||
## QuickStart | ||
|
||
### Development | ||
|
||
```bash | ||
$ npm i | ||
$ npm run dev | ||
$ open http://localhost:7001/ | ||
``` | ||
|
||
Don't tsc compile at development mode, if you had run `tsc` then you need to `npm run clean` before `npm run dev`. | ||
|
||
### Deploy | ||
|
||
```bash | ||
$ npm run tsc | ||
$ npm start | ||
``` | ||
|
||
### Npm Scripts | ||
|
||
- Use `npm run lint` to check code style | ||
- Use `npm test` to run unit test | ||
- se `npm run clean` to clean compiled js at development mode once | ||
|
||
### Requirement | ||
|
||
- Node.js >= 16.x | ||
- Typescript >= 4.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { EggLogger } from 'egg'; | ||
import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum } from '@eggjs/tegg'; | ||
|
||
@HTTPController({ | ||
path: '/', | ||
}) | ||
export class HomeController { | ||
@Inject() | ||
logger: EggLogger; | ||
|
||
@HTTPMethod({ | ||
method: HTTPMethodEnum.GET, | ||
path: '/', | ||
}) | ||
async index() { | ||
this.logger.info('hello egg logger'); | ||
return 'hello egg'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Inject, HTTPController, HTTPMethod, HTTPMethodEnum, HTTPQuery } from '@eggjs/tegg'; | ||
import { HelloService } from '@/module/foo'; | ||
|
||
@HTTPController({ | ||
path: '/bar', | ||
}) | ||
export class UserController { | ||
@Inject() | ||
helloService: HelloService; | ||
|
||
@HTTPMethod({ | ||
method: HTTPMethodEnum.GET, | ||
path: 'user', | ||
}) | ||
async user(@HTTPQuery({ name: 'userId' }) userId: string) { | ||
return await this.helloService.hello(userId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "bar", | ||
"eggModule": { | ||
"name": "bar" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { HelloService } from './service/HelloService'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "foo", | ||
"eggModule": { | ||
"name": "foo" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { EggLogger } from 'egg'; | ||
import { SingletonProto, AccessLevel, Inject } from '@eggjs/tegg'; | ||
|
||
@SingletonProto({ | ||
// 如果需要在上层使用,需要把 accessLevel 显示声明为 public | ||
accessLevel: AccessLevel.PUBLIC, | ||
}) | ||
export class HelloService { | ||
// 注入一个 logger | ||
@Inject() | ||
logger: EggLogger; | ||
|
||
// 封装业务 | ||
async hello(userId: string): Promise<string> { | ||
const result = { userId, handledBy: 'foo module' }; | ||
this.logger.info('[hello] get result: %j', result); | ||
return `hello, ${result.userId}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; | ||
|
||
export default (appInfo: EggAppInfo) => { | ||
const config = {} as PowerPartial<EggAppConfig>; | ||
|
||
// override config from framework / plugin | ||
// use for cookie sign key, should change to your own and keep security | ||
config.keys = appInfo.name + '_1688441299648_5441'; | ||
|
||
// add your egg config in here | ||
config.middleware = []; | ||
|
||
// add your special config in here | ||
const bizConfig = { | ||
sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, | ||
}; | ||
|
||
// the return config will combines to EggAppConfig | ||
return { | ||
...config, | ||
...bizConfig, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { EggAppConfig, PowerPartial } from 'egg'; | ||
|
||
export default () => { | ||
const config: PowerPartial<EggAppConfig> = {}; | ||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { EggAppConfig, PowerPartial } from 'egg'; | ||
|
||
export default () => { | ||
const config: PowerPartial<EggAppConfig> = {}; | ||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { EggPlugin } from 'egg'; | ||
|
||
const plugin: EggPlugin = { | ||
tegg: { | ||
enable: true, | ||
package: '@eggjs/tegg-plugin', | ||
}, | ||
teggConfig: { | ||
enable: true, | ||
package: '@eggjs/tegg-config', | ||
}, | ||
teggController: { | ||
enable: true, | ||
package: '@eggjs/tegg-controller-plugin', | ||
}, | ||
teggSchedule: { | ||
enable: true, | ||
package: '@eggjs/tegg-schedule-plugin', | ||
}, | ||
eventbusModule: { | ||
enable: true, | ||
package: '@eggjs/tegg-eventbus-plugin', | ||
}, | ||
aopModule: { | ||
enable: true, | ||
package: '@eggjs/tegg-aop-plugin', | ||
}, | ||
tracer: { | ||
enable: true, | ||
package: 'egg-tracer', | ||
}, | ||
}; | ||
|
||
export default plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "backend", | ||
"version": "1.0.0", | ||
"description": "platform backend api", | ||
"private": true, | ||
"egg": { | ||
"typescript": true | ||
}, | ||
"scripts": { | ||
"start": "egg-scripts start --daemon --title=egg-server-backend", | ||
"stop": "egg-scripts stop --title=egg-server-backend", | ||
"dev": "egg-bin dev", | ||
"test-local": "egg-bin test -p", | ||
"test": "npm run lint -- --fix && npm run test-local", | ||
"cov": "egg-bin cov -p", | ||
"ci": "npm run lint && npm run cov && npm run tsc && npm run clean", | ||
"lint": "eslint . --ext .ts --cache", | ||
"tsc": "tsc", | ||
"clean": "tsc -b --clean" | ||
}, | ||
"dependencies": { | ||
"@eggjs/tegg": "^3.5.2", | ||
"@eggjs/tegg-aop-plugin": "^3.5.2", | ||
"@eggjs/tegg-config": "^3.2.3", | ||
"@eggjs/tegg-controller-plugin": "^3.5.2", | ||
"@eggjs/tegg-eventbus-plugin": "^3.5.2", | ||
"@eggjs/tegg-plugin": "^3.5.2", | ||
"@eggjs/tegg-schedule-plugin": "^3.5.2", | ||
"egg": "^3.15.0", | ||
"egg-scripts": "^2.17.0", | ||
"egg-tracer": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "10", | ||
"@types/node": "18", | ||
"@eggjs/tsconfig": "1", | ||
"egg-bin": "6", | ||
"egg-mock": "5", | ||
"eslint": "8", | ||
"eslint-config-egg": "12", | ||
"typescript": "4" | ||
}, | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "" | ||
}, | ||
"author": "wmui", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import assert from 'assert'; | ||
import { app } from 'egg-mock/bootstrap'; | ||
|
||
describe('test/app/module/bar/controller/home.test.ts', () => { | ||
it('should GET /', async () => { | ||
const res = await app.httpRequest().get('/'); | ||
assert.equal(res.status, 200); | ||
assert.equal(res.text, 'hello egg'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import assert from 'assert'; | ||
import { app } from 'egg-mock/bootstrap'; | ||
|
||
describe('test/app/module/bar/controller/user.test.ts', () => { | ||
it('should GET /', async () => { | ||
const res = await app.httpRequest().get('/bar/user').query({ userId: '20170901' }); | ||
assert.equal(res.status, 200); | ||
assert.equal(res.text, 'hello, 20170901'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import assert from 'assert'; | ||
import { app } from 'egg-mock/bootstrap'; | ||
import { HelloService } from '@/module/foo/service/HelloService'; | ||
|
||
describe('test/app/module/foo/service/HelloService.test.js', () => { | ||
it('should hello work', async () => { | ||
const helloService = await app.getEggObject(HelloService); | ||
const msg = await helloService.hello('123456'); | ||
assert.equal(msg, 'hello, 123456'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "@eggjs/tsconfig", | ||
"compilerOptions": { | ||
"declaration": false, | ||
"paths": { | ||
"@/module/*": ["app/module/*"] | ||
}, | ||
"baseUrl": "." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This file is created by egg-ts-helper@1.34.7 | ||
// Do not modify this file!!!!!!!!! | ||
/* eslint-disable */ | ||
|
||
import 'egg'; | ||
export * from 'egg'; | ||
export as namespace Egg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This file is created by egg-ts-helper@1.34.7 | ||
// Do not modify this file!!!!!!!!! | ||
/* eslint-disable */ | ||
|
||
import 'egg'; | ||
import { EggAppConfig } from 'egg'; | ||
import ExportConfigDefault from '../../config/config.default'; | ||
type ConfigDefault = ReturnType<typeof ExportConfigDefault>; | ||
type NewEggAppConfig = ConfigDefault; | ||
declare module 'egg' { | ||
interface EggAppConfig extends NewEggAppConfig { } | ||
} |
Oops, something went wrong.