How to use the egg.Agent function in egg

To help you get started, we’ve selected a few egg 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 / test / fixtures / apps / app-ts-type-check / error.ts View on Github external
// service
class MyService extends Service {
  async test() {
    this.ctx.locals.test.serviceLocalCheckAny();
    this.app.config.keys.serviceConfigCheckAny();
    this.app.serviceAppCheckAny();
  }
}
new MyService();

const app = new Application({ baseDir: __dirname, plugins: {}, type: 'application' });
new app.ContextHttpClient();
new app.HttpClient();

new Agent(undefined, 1123);

// test error in yadan
import {
  BaseContextClass as YadanBaseContextClass,
  Application as YadanApplication,
  Agent as YadanAgent,
} from 'yadan';

new YadanBaseContextClass();
const yadan = new YadanApplication({ baseDir: __dirname, plugins: {}, type: 'application' });
new yadan.ContextHttpClient();
new yadan.HttpClient();
new YadanAgent(undefined, 1123);

// config
const config = {} as EggAppConfig;
github eggjs / egg / test / fixtures / apps / app-ts-type-check / normal.ts View on Github external
app.emit('egg-ready');
app.getLogger('test').info('123');
app.inspect();
app.listen(1002);
app.logger.info(app.locals.test);
const ctxHttpClient = new app.ContextHttpClient({} as Context);
ctxHttpClient.request('http://127.0.0.1', { method: 'GET' });
const appHttpClient = new app.HttpClient(app);
appHttpClient.request('http://127.0.0.1', { method: 'GET' });
app.httpclient.request('http://127.0.0.1', { method: 'GET' }).catch(() => {});
app.logger.info(app.Service);
app.logger.info(app.Controller);
app.controller.test().then(() => {});

// agent
const agent = new Agent({ baseDir: __dirname, plugins: {}, type: 'agent' });
agent.logger.info('123');
agent.name.substring(0);
agent.on('egg-ready', () => {});
agent.emit('egg-ready');
agent.getLogger('test').info('123');
agent.inspect();
agent.listen(1002);
agent.httpclient.request('http://127.0.0.1', { method: 'GET' }).catch(() => {});
agent.logger.info(agent.Service);
agent.logger.info(agent.Controller);

// single process mode
start({ baseDir: __dirname,ignoreWarning: true}).then(app=>{
  const port= 1002;
  app.logger.info('123');
  app.on('egg-ready', () => {});