提交 2b6933e6f1cd8a16046d1eeee5cc5d50fba96a81

作者 juvenile
0 个父辈

first commit

  1 +'use strict';
  2 +
  3 +module.exports = {
  4 + write: true,
  5 + prefix: '^',
  6 + plugin: 'autod-egg',
  7 + test: [
  8 + 'test',
  9 + 'benchmark',
  10 + ],
  11 + dep: [
  12 + 'egg',
  13 + 'egg-scripts',
  14 + ],
  15 + devdep: [
  16 + 'egg-ci',
  17 + 'egg-bin',
  18 + 'egg-mock',
  19 + 'autod',
  20 + 'autod-egg',
  21 + 'eslint',
  22 + 'eslint-config-egg',
  23 + ],
  24 + exclude: [
  25 + './test/fixtures',
  26 + './dist',
  27 + ],
  28 +};
  29 +
... ...
  1 +coverage
... ...
  1 +{
  2 + "extends": "eslint-config-egg"
  3 +}
... ...
  1 +logs/
  2 +npm-debug.log
  3 +yarn-error.log
  4 +node_modules/
  5 +package-lock.json
  6 +yarn.lock
  7 +coverage/
  8 +.idea/
  9 +run/
  10 +.DS_Store
  11 +*.sw*
  12 +*.un~
  13 +typings/
  14 +.nyc_output/
  15 +.DS_Store
  16 +yarn-error.lock
\ No newline at end of file
... ...
  1 +
  2 +language: node_js
  3 +node_js:
  4 + - '10'
  5 +before_install:
  6 + - npm i npminstall -g
  7 +install:
  8 + - npminstall
  9 +script:
  10 + - npm run ci
  11 +after_script:
  12 + - npminstall codecov && codecov
... ...
  1 +# hro-egg
  2 +
  3 +
  4 +
  5 +## QuickStart
  6 +
  7 +<!-- add docs here for user -->
  8 +
  9 +see [egg docs][egg] for more detail.
  10 +
  11 +### Development
  12 +
  13 +```bash
  14 +$ npm i
  15 +$ npm run dev
  16 +$ open http://localhost:7001/
  17 +```
  18 +
  19 +### Deploy
  20 +
  21 +```bash
  22 +$ npm start
  23 +$ npm stop
  24 +```
  25 +
  26 +### npm scripts
  27 +
  28 +- Use `npm run lint` to check code style.
  29 +- Use `npm test` to run unit test.
  30 +- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail.
  31 +
  32 +
  33 +[egg]: https://eggjs.org
\ No newline at end of file
... ...
  1 +module.exports = app => {
  2 +
  3 + app.once('server', server => {
  4 +
  5 + })
  6 +
  7 + app.on('error', (err, ctx) => {
  8 +
  9 + })
  10 +
  11 + app.on('request', ctx => {
  12 +
  13 + })
  14 +
  15 + app.on('response', ctx => {
  16 + const used = Date.now() - ctx.starttime
  17 + console.log(used, 'used')
  18 + })
  19 +
  20 +
  21 +}
\ No newline at end of file
... ...
  1 +'use strict';
  2 +
  3 +const Controller = require('egg').Controller;
  4 +
  5 +class HomeController extends Controller {
  6 + async index() {
  7 + const { ctx } = this;
  8 + ctx.body = 'hi, egg';
  9 + }
  10 +}
  11 +
  12 +module.exports = HomeController;
... ...
  1 +'use strict';
  2 +
  3 +/**
  4 + * @param {Egg.Application} app - egg application
  5 + */
  6 +module.exports = app => {
  7 + const { router, controller } = app;
  8 + router.get('/', controller.home.index);
  9 +};
... ...
  1 +environment:
  2 + matrix:
  3 + - nodejs_version: '10'
  4 +
  5 +install:
  6 + - ps: Install-Product node $env:nodejs_version
  7 + - npm i npminstall && node_modules\.bin\npminstall
  8 +
  9 +test_script:
  10 + - node --version
  11 + - npm --version
  12 + - npm run test
  13 +
  14 +build: off
... ...
  1 +/* eslint valid-jsdoc: "off" */
  2 +
  3 +'use strict';
  4 +
  5 +const path = require('path')
  6 +/**
  7 + * @param {Egg.EggAppInfo} appInfo app info
  8 + */
  9 +module.exports = appInfo => {
  10 + /**
  11 + * built-in config
  12 + * @type {Egg.EggAppConfig}
  13 + **/
  14 + const config = exports = {};
  15 + // use for cookie sign key, should change to your own and keep security
  16 + config.keys = appInfo.name + '_1642067379356_9612';
  17 +
  18 + // add your middleware config here
  19 + config.middleware = [];
  20 +
  21 + // add your user config here
  22 + const userConfig = {
  23 + // myAppName: 'egg',
  24 + };
  25 +
  26 + const view = {
  27 + root: path.join(appInfo.baseDir, 'app/public'),
  28 + defaultViewEngine: 'nunjucks',
  29 + mapping: {
  30 + '.html': 'nunjucks',
  31 + }
  32 + }
  33 +
  34 + config.cluster = {
  35 + listen: {
  36 + path: '',
  37 + port: 8001,
  38 + hostname: '0.0.0.0',
  39 + }
  40 + };
  41 +
  42 + config.static = {
  43 + prefix: '',
  44 + dir: path.join(appInfo.baseDir, 'app/public'),
  45 + dynamic: true,//是否緩存靜態資源
  46 + preload: false,//啓動項目開啓緩存
  47 + maxAge: 0, //緩存時間 開發建議設0 跳坑
  48 + buffer: false//是否緩存到内存 默認prod 緩存
  49 + };
  50 +
  51 + return {
  52 + ...config,
  53 + ...userConfig,
  54 + };
  55 +};
... ...
  1 +'use strict';
  2 +
  3 +/** @type Egg.EggPlugin */
  4 +module.exports = {
  5 + // had enabled by egg
  6 + // static: {
  7 + // enable: true,
  8 + // }
  9 +};
... ...
  1 +{
  2 + "include": [
  3 + "**/*"
  4 + ]
  5 +}
\ No newline at end of file
... ...
  1 +{
  2 + "name": "hro-egg",
  3 + "version": "1.0.0",
  4 + "description": "",
  5 + "private": true,
  6 + "egg": {
  7 + "declarations": true
  8 + },
  9 + "dependencies": {
  10 + "egg": "^2.15.1",
  11 + "egg-scripts": "^2.11.0"
  12 + },
  13 + "devDependencies": {
  14 + "autod": "^3.0.1",
  15 + "autod-egg": "^1.1.0",
  16 + "egg-bin": "^4.11.0",
  17 + "egg-ci": "^1.11.0",
  18 + "egg-mock": "^3.21.0",
  19 + "eslint": "^5.13.0",
  20 + "eslint-config-egg": "^7.1.0"
  21 + },
  22 + "engines": {
  23 + "node": ">=10.0.0"
  24 + },
  25 + "scripts": {
  26 + "start": "egg-scripts start --daemon --title=egg-server-hro-egg",
  27 + "stop": "egg-scripts stop --title=egg-server-hro-egg",
  28 + "dev": "egg-bin dev",
  29 + "debug": "egg-bin debug",
  30 + "test": "npm run lint -- --fix && npm run test-local",
  31 + "test-local": "egg-bin test",
  32 + "cov": "egg-bin cov",
  33 + "lint": "eslint .",
  34 + "ci": "npm run lint && npm run cov",
  35 + "autod": "autod"
  36 + },
  37 + "ci": {
  38 + "version": "10"
  39 + },
  40 + "repository": {
  41 + "type": "git",
  42 + "url": ""
  43 + },
  44 + "author": "",
  45 + "license": "MIT"
  46 +}
... ...
注册登录 后发表评论