一.node-js后台服务器创建
https://mlab.com/ monggoDb数据库
https://www.heroku.com node后台服务器
二.后台关联
1.keys.js
monggoDb数据关联
module.exports = {
mongoURI: 'mongodb://user:password@ds223542.mlab.com:23542/taxware-api',
secretOrKey: 'secret'
};
2.node后台上传heroku服务器
首先下载安装heroku-cli工具
https://devcenter.heroku.com/articles/heroku-cli
1.后台代码git到本地仓库
2.命令行中上传代码到heroku服务器
命令如下:
PS C:UsersAdministratorDesktopjd-interface> heroku login //命令中登录heroku heroku: Press any key to open up the browser to login or q to exit: » Warning: If browser does not open, visit » https://cli-auth.heroku.com/auth/browser/d33e41e0-4afe-4ad4-8c2e-64968973f718 Logging in... done Logged in as sjxajhhaozi@foxmail.com //登录成功标志 PS C:UsersAdministratorDesktopjd-interface> heroku create //创建服务器应用 Creating app... done, ⬢ shrouded-headland-66332 //创建后的应用名字 https://shrouded-headland-66332.herokuapp.com/ | https://git.heroku.com/shrouded-headland-66332.git PS C:UsersAdministratorDesktopjd-interface> heroku git:remote -a shrouded-headland-66332 //本地git仓库关联heroku set git remote heroku to https://git.heroku.com/shrouded-headland-66332.git PS C:UsersAdministratorDesktopjd-interface> git push heroku master //后台代码上传到heroku Enumerating objects: 200, done. Counting objects: 100% (200/200), done. Delta compression using up to 4 threads Compressing objects: 100% (181/181), done. Writing objects: 100% (200/200), 41.27 KiB | 358.00 KiB/s, done. Total 200 (delta 73), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: NODE_VERBOSE=false remote: remote: -----> Installing binaries remote: engines.node (package.json): unspecified remote: engines.npm (package.json): unspecified (use default) remote: remote: Resolving node version 10.x... remote: Downloading and installing node 10.13.0... remote: Using default npm version: 6.4.1 remote: remote: -----> Building dependencies remote: Installing node modules (package.json + package-lock) remote: remote: > bcrypt@2.0.1 install /tmp/build_6e5670a3cba76a8761ecd1e7cf3f0284/node_modules/bcrypt remote: > node-pre-gyp install --fallback-to-build remote: remote: [bcrypt] Success: "/tmp/build_6e5670a3cba76a8761ecd1e7cf3f0284/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote remote: added 210 packages from 130 contributors and audited 388 packages in 6.039s remote: found 1 low severity vulnerability remote: run `npm audit fix` to fix them, or `npm audit` for details remote: remote: -----> Caching build remote: - node_modules remote: remote: -----> Pruning devDependencies remote: audited 388 packages in 1.908s remote: found 1 low severity vulnerability remote: run `npm audit fix` to fix them, or `npm audit` for details remote: remote: -----> Build succeeded! remote: -----> Discovering process types remote: Procfile declares types -> (none) remote: Default types for buildpack -> web remote: remote: -----> Compressing... remote: Done: 20.9M remote: -----> Launching... remote: Released v3 remote: https://shrouded-headland-66332.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/shrouded-headland-66332.git * [new branch] master -> master PS C:UsersAdministratorDesktopjd-interface> heroku open //检查是否成功
三.微信小程序开发者注册
https://developers.weixin.qq.com/miniprogram/dev/
参考官方开发文档进行注册操作创建