Skip to content

Instantly share code, notes, and snippets.

View zavr-1's full-sized avatar
๐Ÿ
Depack: Front-End Code and Node.JS Package Bundler With Google Closure Compiler.

zavr-1

๐Ÿ
Depack: Front-End Code and Node.JS Package Bundler With Google Closure Compiler.
View GitHub Profile
<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>
@zavr-1
zavr-1 / session.js
Last active December 26, 2019 12:10
/**
* @type {_idio.session}
*/
function Session(opts = {}) {
formatOpts(opts)
/**
* @type {!_idio.Middleware}
*/
async function session(ctx, next) {
{
"_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": {
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
// ENTRY FILE
const { _Goa, _Context } = require('./koa')
/**
* An application constructor.
* @type {new (options?: ApplicationOptions) => Application)}
*/
const $Goa = _Goa
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));
@zavr-1
zavr-1 / koa-api.js
Last active December 23, 2019 14:10
/**
* Set accept object.
* @api private NOT JSDOC
*/
set accept(obj) {
this._accept = obj;
},
/**
* Return request header.
* @api public NOT JSDOC
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
}
/**
* Context prototype.
*/
const proto = module.exports = {
/**
* Return JSON representation.
*
*/
@zavr-1
zavr-1 / koa.js
Last active December 23, 2019 13:37
// KOA
'use strict';
/**
* Module dependencies.
*/
const util = require('util');
const createError = require('http-errors');