npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ee-express

v0.3.5

Published

a essy enterprice express project template

Downloads

105

Readme

ee-express:

1. EEExpress.utils

  • httpClient 发起Http请求。
    • httpClient.get(options|Object) GET请求,options属性有:host,url,query
    • httpClient.post(options|Object) POST请求,options属性有:host,url,body
    #示例:
    httpClient.get({
      host:'http://10.200.10.22:28080',
      url: '/user/list',
      query: {
        name: 'admin'
      }
    }).then(res => {
      console.log(res)
    })
    
    httpClient.post({
      host:'http://10.200.10.22:28080',
      url: '/login',
      body: {
        name: 'admin',
        pwd: '12345'
      }
    }).then(res => {
      console.log(res)
    })
  • file
    • Array getFiles(path|String) 获取指定路径下的所有文件,最终会返回一个文件清单Array
    • void mkdirsSync(dirpath|String) 创建一个不存在的文件夹,如果父文件夹不存在会自动创建
    • void requireDirectory(directory|String, target|Object)将某个文件夹下的所有文件输出包装到target对象下
    • Object moduleDirectory(fullDirectory|String) 将某个文件夹下的所有文件输出包装为一个模块,并返回。属性名自动转换为驼峰格式。
    • PromiseObject zipFolderAsync(srcFolder|String, zipDirectory|String, fileName|String) 异步打包某一个文件夹到另外一个文件夹
    • void copy(source|String, target|String) 拷贝文件或者文件夹
    • void rm(rmPath|String, delRoot|Boolean) 递归删除指定的文件夹,并可以指定是否删除最顶端的文件夹
  • codes
  • email
  • tools
  • validator

2. 创建EEExpress实例

let instance = new EEExpress(config|Object, rootPath|String)

config

如果instance启动的时候不指定配置,则使用./configs文件夹下对应环境变量的配置文件。如果没有指定环境变量,则默认使用的是./configs/index.js文件的配置

rootPath

当前instance启动时可以指定其进程执行根目录,如果不指定,则默认会以当前process.cwd()作为其rootPath。在配置文件内的所有路径相关的设置都会以当前的rootPath作为基础路径。 instance.init() instance的初始化,app会根据当前加载的配置项进行初始化。

instance.setConfig(config)

instance在启动之前可以通过setConfig方法指定其执行环境。不过此方法必须在init执行之前执行。否则设置无法生效。

instance.authRegister([Array|Function])

instance可以通过此方法来注册自己的用户授权规则。其内置支持白名单功能,可在配置文件中设置writeList配置项。==此处需要注意==配置文件中的disableAuthorize的优先级最高,如果其配置项设置为true,则整个授权体系即被禁用。

app.config

app运行时生效的配置项。

关于配置文件中的路径

如果设置的路径为空字符串,则系统不会加载对应的模块。比如: view: '',则instance不会设置view

默认配置:

/**
 * @author: jiangfeng
 * @summary: basic config
 */
module.exports = {
  appName: 'eeExpress',
  proxyHost: 'http://10.200.10.22:28080',
  proxyApiPrefix: 'api',
  disableAuthorize: true,
  disableOrmMapping: true,
  disableSession: false,
  disableLog: false,
  disableInternational: true,
  disableGzip: false,
  directory: {
    static: './static',
    view: './views',
    service: './services',
    router: './routers',
    module: './modules'
  },
  writeList: {
    routers: ['/', '/login'],
    services: []
  },
  listenPort: '6666',
  requestHeaders: [
    ['Access-Control-Allow-Origin', '*'],
    ['Access-Control-Allow-Headers', 'accept, content-type'],
    ['X-Powered-By', 'eeExpress']
  ],
  pages: {
    loginUrl: '/login',
    errorUrl: '/404'
  },
  session: {
    // 默认两天过期
    maxAge: 7200000,
    // 支持memory,redis
    store: 'memory',
    prefix: 'eeExpress:',
    secret: 'eeExpress',
    name: 'eeExpress',
    // 每个请求都重新设置一个 cookie,默认为 false。
    rolling: true,
    // 即使 session 没有被修改,也保存 session 值,默认为 true。
    resave: true,
    saveUninitialized: true
  },
  log: 'log4js',
  log4js: {
    customBaseDir: './logs/',
    customDefaultAtt: {
      type: 'dateFile',
      absolute: false,
      alwaysIncludePattern: true
    },
    appenders: [
      {
        type: 'console'
      },
      {
        pattern: 'yyyy-MM-dd/service-name/debug.log',
        category: 'logDebug'
      },
      {
        pattern: 'yyyy-MM-dd/service-name/info.log',
        category: 'logInfo'
      },
      {
        pattern: 'yyyy-MM-dd/service-name/warn.log',
        category: 'logWarn'
      },
      {
        pattern: 'yyyy-MM-dd/service-name/err.log',
        category: 'logErr'
      }
    ],
    replaceConsole: true,
    levels: {
      logDebug: 'ALL',
      logInfo: 'ALL',
      logWarn: 'ALL',
      logErr: 'ALL'
    }
  },
  redis: {
    mode: 'local', // cluster
    prefix: 'eeExpress:',
    local: {
      port: 6379,
      host: '127.0.0.1'
    }
  },
  i18n: {
    locales: ['en-US', 'zh-CN'],
    defaultLocale: 'zh-CN',
    directory: './locales',
    updateFiles: false,
    autoReload: true,
    cookie: 'lang',
    queryParameter: 'lang',
    indent: '\t',
    extension: '.json'
  },
  email: {
    service: 'qq',
    port: 465,
    secureConnection: true,
    auth: {
      user: '[email protected]',
      pass: 'dhrrpvicchuobhij'
    }
  },
  orm: {
    modelsRoot: './models',
    connections: {
      default: {
        adapter: 'mongo',
        hostname: 'localhost',
        port: 27017,
        user: 'jiangfeng',
        password: 'Aaa12345!!',
        database: 'sails'
      }
    },
    defaults: {
      migrate: 'safe'
    }
  }
}