Applet learning diary 3

1.app property
parsing:
[1] app.env: The default is NODE_ENV or "Development"
[2] app.keys: the cookie key array signed
[3] app.proxy: When real-Agent header field will be trusted when
[4] app.subdomainOffset .subdomains negligible offset, the default is 2
[. 5] app.proxyIpHeader: ip proxy header, the default is the For-Forwarded-X-
[. 6] app.maxIpsCount: reading the header from the proxy ip the maximum ips, defaults to 0 [representatives unlimited]

2.app.listen (...) the nature of
analysis:

const http = require('http');
const Koa = require('koa');
const app = new Koa();
http.createServer(app.callback()).listen(3000);

3.app.callback ()
Analysis: Returns the apply callback function http.createServer () method to process the request. You can also use this callback function koa application to mount Connect / Express applications.

4.app.use (function)
Analysis: middleware given way to add to this application.

5.app.context
resolved:
[1] app.context is created from ctx prototype. App.context can add other attributes by editing ctx.
[2] Many properties are used in the ctx getter, setter and Object.defineProperty () is defined. Only by using Object.defineProperty on app.context () to edit these properties [not recommended].
[3] Koa Context node of the request and response objects packaged into a single object, there is provided a method for the preparation of many useful applications and Web API.

6.ctx.req
resolved: Node request object.

7.ctx.res
resolved: Node of the response object.

8.ctx.request
resolved: koa Request object.

9.ctx.response
resolved: koa Response object.

10.ctx.state
Analysis: Recommended namespace, for communicating information, and a front end view through the middleware.

11.ctx.app
analysis: application instance reference.

12.ctx.app.emit
resolve: Koa application extends the internal EventEmitter. ctx.app.emit an event that type defined by the first argument. For each event, you can connect "listeners", which is a function called when issuing event.

13.ctx.cookies.get (name, [options])
Analysis: cookiename get through options.

14.ctx.cookies.set (name, value, [options
]) Analysis: The value provided by cookiename options.

15.ctx.throw ([status], [msg
], [properties]) Analytical: Helper method throws an error .status default attribute 500, which will allow to make Koa respond appropriately.

16.ctx.assert (value, [status],
[msg], [properties]) Analysis:! When the value when, Helper method throws like .throw () error. This node is similar to the assert () method.

17.ctx.respond
Analysis: In order to bypass the built-response process Koa may explicitly set ctx.respond = false ;. If you want to write the original res object rather than let Koa treatment response, please use this parameter.

18.Request别名
解析:以下访问器和Request别名等效:
[1]ctx.header
[2]ctx.headers
[3]ctx.method
[4]ctx.method=
[5]ctx.url
[6]ctx.url=
[7]ctx.originalUrl
[8]ctx.origin
[9]ctx.href
[10]ctx.path
[11]ctx.path=
[12]ctx.query
[13]ctx.query=
[14]ctx.querystring
[15]ctx.querystring=
[16]ctx.host
[17]ctx.hostname
[18]ctx.fresh
[19]ctx.stale
[20]ctx.socket
[21]ctx.protocol
[22]ctx.secure
[23]ctx.ip
[24]ctx.ips
[25]ctx.subdomains
[26]ctx.is()
[27]ctx.accepts()
[28]ctx.acceptsEncodings()
[29]ctx.acceptsCharsets()
[30]ctx.acceptsLanguages()
[31]ctx.get()

19.Response别名
解析:以下访问器和Response别名等效:
[1]ctx.body
[2]ctx.body=
[3]ctx.status
[4]ctx.status=
[5]ctx.message
[6]ctx.message=
[7]ctx.length=
[8]ctx.length
[9]ctx.type=
[10]ctx.type
[11]ctx.headerSent
[12]ctx.redirect()
[13]ctx.attachment()
[14]ctx.set()
[15]ctx.append()
[16]ctx.remove()
[17]ctx.lastModified=
[18]ctx.etag=

20. Cloud Development
Analysis: Cloud Development provides complete support for cloud databases, cloud storage, and functions as the developer. No need to set up the server, API using the platform provided by the core business development, to achieve a small rapid on-line program and iteration.

21.wx.getSetting (Object object)
Analysis: get the user's current settings. Applet has requested permission to the user through the return value will appear. object.success callback function:
[. 1] authSetting: User authorization result
[2] subscriptionsSetting: user subscription message set, the interface parameters withSubscriptions will return value is true.

22.AuthSetting user authorization setting information
parsed:
[. 1] Boolean scope.userInfo : whether to authorize the user information, the corresponding interface wx.getUserInfo
[2] Boolean scope.userLocation : location is authorized, the corresponding interface wx.getLocation, wx.chooseLocation
[ . 3] Boolean scope.address : whether to authorize communications address, the corresponding interface wx.chooseAddress
[. 4] Boolean scope.invoiceTitle : invoice is authorized, the corresponding interface wx.chooseInvoiceTitle
[. 5] Boolean scope.invoice : obtaining the invoice is authorized, the corresponding interface wx.chooseInvoice
[. 6] Boolean scope.werun : whether to authorize the movement step number of the micro-channel, the corresponding interface wx.getWeRunData
[. 7] Boolean scope.record : recording function is authorized, the corresponding interface wx.startRecord
[. 8] Boolean scope.writePhotosAlbum: To save the album is authorized wx.saveImageToPhotosAlbum, wx.saveVideoToPhotosAlbum
[. 9] Boolean scope.camera : whether to authorize the camera, the corresponding camera assembly

23.wx.getUserInfo (Object object) is the callback function object.success
resolved:
[. 1] the userInfo : a user information object does not contain sensitive information like openid
[2] the rawData : original data string does not include sensitive information, for calculating signature
[. 3] signature : using sha1 (rawData + sessionkey) to give the string, for verifying the user information
[. 4] encryptedData : encrypted data comprises sensitive data, including a complete user information
[. 5] IV : encryption algorithm initial vector
[. 6] cloudID : sensitive ID data corresponding to the cloud, the cloud developing small opening will not return, the data can be obtained directly through the cloud calling open

24.UserInfo user information
parsed:
[1] String NICKNAME: Nickname
[2] string avatarUrl: URL the user avatar picture.
[3] number gender: Gender
[4] string country: the user's country
[5] string province: user where the provinces
[6] string city: the user's city
[7] string language: Language country, province, city used

25.display
resolved: display attribute specifies the type of element to be generated box. As follows:
[. 1] none: This element is not displayed.
[2] block: This element will appear as a block-level element, with a line break before and after this element will.
[3] inline: default. This element will be displayed as inline elements, before and after the element has no line breaks.
[4] inline-block: block elements within a row. [CSS 2.1 Added value]
[5] the inherit: the provisions should inherit the value of the display property from the parent element.

参考文献:
[1]pillarjs/cookies:https://github.com/pillarjs/cookies
[2]jshttp/http-errors:https://github.com/jshttp/http-errors
[3]jshttp/http-assert:https://github.com/jshttp/http-assert
[4]koajs/examples:https://github.com/koajs/examples
[5]koajs/koa:https://github.com/koajs/koa/wiki

Published 364 original articles · won praise 422 · views 360 000 +

Guess you like

Origin blog.csdn.net/shengshengwang/article/details/104382294