This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<types ns="_idio"> | |
<import from="@typedefs/goa" ns="_goa" name="Middleware" /> | |
<method name="session" return="!_goa.Middleware"> | |
<arg type="!_idio.SessionConfig" name="opts" opt> | |
The configuration passed to `koa-session`. | |
</arg> | |
Initialize the session middleware with `opts`. | |
</method> | |
</types> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @type {_idio.session} | |
*/ | |
function Session(opts = {}) { | |
formatOpts(opts) | |
/** | |
* @type {!_idio.Middleware} | |
*/ | |
async function session(ctx, next) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_goa.Router": { | |
"link": "https://github.com/idiocc/goa-router/wiki/Home#type-router", | |
"description": "Router For Goa Apps." | |
}, | |
"_goa.AllowedMethodsOptions": { | |
"link": "https://github.com/idiocc/goa-router/wiki/Home#type-allowedmethodsoptions", | |
"description": "The options for the `allowedMethods` middleware generation." | |
}, | |
"_goa.RouterConfig": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export {} | |
/* typal types/Application.xml namespace */ | |
/** | |
* @typedef {import('http').IncomingMessage} http.IncomingMessage | |
* @typedef {import('http').ServerResponse} http.ServerResponse | |
* @typedef {import('http').Server} http.Server | |
* @typedef {import('events').EventEmitter} events.EventEmitter | |
* @typedef {import('../../compile').Keygrip} _goa.Keygrip | |
* @typedef {import('../../compile').Context} _goa.Context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ENTRY FILE | |
const { _Goa, _Context } = require('./koa') | |
/** | |
* An application constructor. | |
* @type {new (options?: ApplicationOptions) => Application)} | |
*/ | |
const $Goa = _Goa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('string' === typeof body) return Buffer.byteLength(body); | |
return typeof this.res.hasHeader === 'function' | |
if (Array.isArray(val)) val = val.map(v => typeof v === 'string' ? v : String(v)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set accept object. | |
* @api private NOT JSDOC | |
*/ | |
set accept(obj) { | |
this._accept = obj; | |
}, | |
/** | |
* Return request header. | |
* @api public NOT JSDOC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get subdomains() { | |
const offset = this.app.subdomainOffset; // no | |
const hostname = this.hostname; // no | |
if (net.isIP(hostname)) return []; // no | |
return hostname | |
.split('.') | |
.reverse() | |
.slice(offset); // no | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Context prototype. | |
*/ | |
const proto = module.exports = { | |
/** | |
* Return JSON representation. | |
* | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// KOA | |
'use strict'; | |
/** | |
* Module dependencies. | |
*/ | |
const util = require('util'); | |
const createError = require('http-errors'); |