How to use the egg-core.utils function in egg-core

To help you get started, we’ve selected a few egg-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eggjs / egg / lib / application.js View on Github external
'use strict';

const path = require('path');
const fs = require('fs');
const ms = require('ms');
const is = require('is-type-of');
const graceful = require('graceful');
const http = require('http');
const cluster = require('cluster-client');
const onFinished = require('on-finished');
const { assign } = require('utility');
const eggUtils = require('egg-core').utils;
const EggApplication = require('./egg');
const AppWorkerLoader = require('./loader').AppWorkerLoader;

const KEYS = Symbol('Application#keys');
const HELPER = Symbol('Application#Helper');
const LOCALS = Symbol('Application#locals');
const BIND_EVENTS = Symbol('Application#bindEvents');
const WARN_CONFUSED_CONFIG = Symbol('Application#warnConfusedConfig');
const EGG_LOADER = Symbol.for('egg#loader');
const EGG_PATH = Symbol.for('egg#eggPath');
const CLUSTER_CLIENTS = Symbol.for('egg#clusterClients');
const RESPONSE_RAW = Symbol('Application#responseRaw');

// client error => 400 Bad Request
// Refs: https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_event_clienterror
const DEFAULT_BAD_REQUEST_HTML = `
github eggjs / egg-mock / lib / context.js View on Github external
'use strict';

// try to use eggUtils.getCalleeFromStack
// ignore it if egg-core module not found
let eggUtils;
try {
  eggUtils = require('egg-core').utils;
  if (!eggUtils) {
    // try to support egg-core@3
    eggUtils = require('egg-core/lib/utils');
  }
} catch (_) {
  // ignore eggUtils
}

module.exports = {
  runInBackground(scope) {
    /* istanbul ignore next */
    const taskName = scope._name || scope.name || (eggUtils && eggUtils.getCalleeFromStack(true));
    if (taskName) {
      scope._name = taskName;
    }
github eggjs / egg / app / extend / context.js View on Github external
'use strict';

const delegate = require('delegates');
const { assign } = require('utility');
const eggUtils = require('egg-core').utils;

const HELPER = Symbol('Context#helper');
const LOCALS = Symbol('Context#locals');
const LOCALS_LIST = Symbol('Context#localsList');
const COOKIES = Symbol('Context#cookies');
const CONTEXT_LOGGERS = Symbol('Context#logger');
const CONTEXT_HTTPCLIENT = Symbol('Context#httpclient');
const CONTEXT_ROUTER = Symbol('Context#router');

const proto = module.exports = {

  /**
   * Get the current visitor's cookies.
   */
  get cookies() {
    if (!this[COOKIES]) {
github eggjs / egg / app / extend / context.js View on Github external
'use strict';

const delegate = require('delegates');
const { assign } = require('utility');
const eggUtils = require('egg-core').utils;

const HELPER = Symbol('Context#helper');
const LOCALS = Symbol('Context#locals');
const LOCALS_LIST = Symbol('Context#localsList');
const COOKIES = Symbol('Context#cookies');
const CONTEXT_LOGGERS = Symbol('Context#logger');
const CONTEXT_HTTPCLIENT = Symbol('Context#httpclient');
const CONTEXT_ROUTER = Symbol('Context#router');

const proto = module.exports = {

  /**
   * Get the current visitor's cookies.
   */
  get cookies() {
    if (!this[COOKIES]) {

egg-core

A core Pluggable framework based on koa

MIT
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis