How to use the mali function in mali

To help you get started, we’ve selected a few mali 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 neo-one-suite / neo-one / packages / neo-one-server / src / Server.ts View on Github external
this.mutableServerDebug.pid = process.pid;

                await manager.writeVersionPID(process.pid, VERSION);
              } else if (pid !== process.pid) {
                throw new ServerRunningError(pid);
              }
            } else {
              await prevApp.close().catch((error: Error) => {
                this.monitor.logError({
                  name: 'grpc_app_close_error',
                  message: 'Failed to close previous app',
                  error,
                });
              });
            }
            const app = new Mali(proto);
            app.silent = false;
            app.on('error', (error: Error, ctx: Context | undefined | null) => {
              let monitor = this.monitor;
              // tslint:disable-next-line:no-any
              if (ctx != undefined && (ctx as any).state != undefined && (ctx as any).state.monitor != undefined) {
                // tslint:disable-next-line:no-any
                ({ monitor } = (ctx as any).state);
              }
              monitor.logError({
                name: 'grpc_server_request_uncaught_error',
                message: 'Uncaught grpc error.',
                error,
              });
            });
            app.use(context({ monitor: this.monitor }));
            app.use(servicesMiddleware({ server: this }));
github benjsicam / node-graphql-microservices / grpc-services / posts / src / main.js View on Github external
cache = new Redis(redisOptions)
  }

  const cacheService = new CacheService(cache, logger)
  const cacheMiddleware = new CacheMiddleware(cacheService, logger)

  const PostService = {
    findAll: [cacheMiddleware.find('posts'), repo.findAll.bind(repo)],
    findOne: [cacheMiddleware.read('posts'), repo.findOne.bind(repo)],
    count: repo.count.bind(repo),
    create: [cacheMiddleware.write('posts'), repo.create.bind(repo)],
    update: [cacheMiddleware.write('posts'), repo.update.bind(repo)],
    destroy: [cacheMiddleware.remove('posts'), repo.destroy.bind(repo)]
  }

  const app = new Mali()
  const healthCheckService = new HealthCheckService(SERVICE_NAME)
  const healthCheckImpl = await healthCheckService.getServiceImpl()

  app.addService(SERVICE_PROTO, null, {
    enums: String,
    objects: true,
    arrays: true
  })
  app.addService(service)

  app.use({
    PostService,
    ...healthCheckImpl
  })

  await app.start(HOST_PORT)
github benjsicam / node-graphql-microservices / grpc-services / comments / src / main.js View on Github external
cache = new Redis(redisOptions)
  }

  const cacheService = new CacheService(cache, logger)
  const cacheMiddleware = new CacheMiddleware(cacheService, logger)

  const CommentService = {
    findAll: [cacheMiddleware.find('comments'), repo.findAll.bind(repo)],
    findOne: [cacheMiddleware.read('comments'), repo.findOne.bind(repo)],
    count: repo.count.bind(repo),
    create: [cacheMiddleware.write('comments'), repo.create.bind(repo)],
    update: [cacheMiddleware.write('comments'), repo.update.bind(repo)],
    destroy: [cacheMiddleware.remove('comments'), repo.destroy.bind(repo)]
  }

  const app = new Mali()
  const healthCheckService = new HealthCheckService(SERVICE_NAME)
  const healthCheckImpl = await healthCheckService.getServiceImpl()

  app.addService(SERVICE_PROTO, null, {
    enums: String,
    objects: true,
    arrays: true
  })
  app.addService(service)

  app.use({
    CommentService,
    ...healthCheckImpl
  })

  await app.start(HOST_PORT)
github benjsicam / node-graphql-microservices / grpc-services / mailer / src / main.js View on Github external
host: process.env.SMTP_HOST,
    port: process.env.SMTP_PORT,
    secure: process.env.SMTP_SECURE,
    auth: {
      user: process.env.SMTP_USER,
      pass: process.env.SMTP_PASS
    }
  })

  const mailerClient = new MailerClientService(transporter, logger, SERVICE_NAME)

  const MailerService = {
    send: mailerClient.send.bind(mailerClient)
  }

  const app = new Mali()
  const healthCheckService = new HealthCheckService(SERVICE_NAME)
  const healthCheckImpl = await healthCheckService.getServiceImpl()

  app.addService(SERVICE_PROTO, null, {
    enums: String,
    objects: true,
    arrays: true
  })
  app.addService(service)

  app.use({
    MailerService,
    ...healthCheckImpl
  })

  await app.start(HOST_PORT)
github benjsicam / node-graphql-microservices / grpc-services / users / src / main.js View on Github external
cache = new Redis(redisOptions)
  }

  const cacheService = new CacheService(cache, logger)
  const cacheMiddleware = new CacheMiddleware(cacheService, logger)

  const UserService = {
    findAll: [cacheMiddleware.find('users'), repo.findAll.bind(repo)],
    findOne: [cacheMiddleware.read('users'), repo.findOne.bind(repo)],
    count: repo.count.bind(repo),
    create: [cacheMiddleware.write('users'), repo.create.bind(repo)],
    update: [cacheMiddleware.write('users'), repo.update.bind(repo)],
    destroy: [cacheMiddleware.remove('users'), repo.destroy.bind(repo)]
  }

  const app = new Mali()
  const healthCheckService = new HealthCheckService(SERVICE_NAME)
  const healthCheckImpl = await healthCheckService.getServiceImpl()

  app.addService(SERVICE_PROTO, null, {
    enums: String,
    objects: true,
    arrays: true
  })
  app.addService(service)

  app.use({
    UserService,
    ...healthCheckImpl
  })

  await app.start(HOST_PORT)
github neo-one-suite / neo-one / packages / neo-one-server / src / Server.js View on Github external
this._serverDebug.pid = process.pid;

                manager.writePID(process.pid);
              } else if (pid !== process.pid) {
                throw new ServerRunningError(pid);
              }
            } else {
              await prevApp.close().catch((error) => {
                this._monitor.logError({
                  name: 'grpc_app_close_error',
                  message: 'Failed to close previous app',
                  error,
                });
              });
            }
            const app = new Mali(proto);
            app.silent = false;
            app.on('error', (error, ctx) => {
              let monitor = this._monitor;
              if (
                ctx != null &&
                ctx.state != null &&
                ctx.state.monitor != null
              ) {
                ({ monitor } = ctx.state);
              }
              monitor.logError({
                name: 'grpc_server_request_uncaught_error',
                message: 'Uncaught grpc error.',
                error,
              });
            });

mali

Minimalistic gRPC microservice framework

Apache-2.0
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis

Popular mali functions