项目作者: GreyHanky

项目描述 :
使用hapi/typescript开发的微信小程序服务
高级语言: TypeScript
项目地址: git://github.com/GreyHanky/hapi-ts-wechat-applet-server.git
创建时间: 2019-05-23T08:11:07Z
项目社区:https://github.com/GreyHanky/hapi-ts-wechat-applet-server

开源协议:

下载


hapi-ts-wechat-applet-server

使用 hapi/typescript 开发的微信小程序服务

安装依赖

  1. $ npm install

开发

  1. $ npm run dev

项目配置

mysql 配置以及项目端口配置在 src/configurations
config.db.json - 数据库配置

  1. {
  2. // 用户名
  3. "username": "root",
  4. // 数据库密码
  5. "password": "831015",
  6. // 数据库
  7. "database": "dev_weChat_applet",
  8. // 链接端口
  9. "host": "localhost",
  10. "dialect": "mysql"
  11. }

config.env.json

  1. {
  2. "weChat": {
  3. "wxAppid": "wx6646cee3ccecceaa",
  4. "wxSecret": "a413d6545e63a35fc2a0336d66534b89"
  5. },
  6. "server": {
  7. // 服务端口
  8. "port": 3000,
  9. // 服务host
  10. "host": "localhost",
  11. // 认证使用jwt方式(自定义secret
  12. "jwtSecret": "random-secret-password",
  13. // 过期时间
  14. "jwtExpiration": "1h",
  15. // 路由前缀
  16. "routePrefix": "",
  17. // 需要使用的插件(与src/plugin下文件名相同,会自动引入插件)
  18. "plugins": [
  19. "hapi-auth-jwt2",
  20. "hapi-pagination",
  21. "hapi-swagger",
  22. "hapi-pino"
  23. ]
  24. }
  25. }

脚本命令

创建一个 api 模版

在 src/api 下创建一条路由

  1. $ npm run createApi [apiName]

数据库迁移(Sequelize CLI)

执行数据库迁移

  1. $ npm run db:migrate

创建一个迁移文件

  1. $ npm run db:generate [tabname]

撤销全部或一个迁移文件

  1. $ npm run db:undo -a | tableFileName