How to use the @fullstack-one/di.Service function in @fullstack-one/di

To help you get started, we’ve selected a few @fullstack-one/di 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 fullstack-build / fullstack-one / packages / schema-builder / lib / db-schema-builder / index.ts View on Github external
import * as _ from "lodash";
import * as fastGlob from "fast-glob";
import * as fs from "fs";
import { diff } from "deep-diff";

import { BootLoader } from "@fullstack-one/boot-loader";
import { Service, Container, Inject } from "@fullstack-one/di";
import { Config, IEnvironment } from "@fullstack-one/config";
import { LoggerFactory, ILogger } from "@fullstack-one/logger";
import { DbAppClient, PgClient } from "@fullstack-one/db";
import { IDbMeta } from "./IDbMeta";
import { MigrationObject } from "./migrationObject";
import { SqlObjFromMigrationObject } from "./toPg/createSqlObjFromMigrationObject";

@Service()
export class DbSchemaBuilder {
  private fromDbMeta: IDbMeta;
  private toDbMeta: IDbMeta;
  private migrationObject: MigrationObject;
  private dbAppClient: DbAppClient;
  private initSqlPaths = [`${__dirname}/../..`];
  private dbConfig;
  private schemaBuilderConfig;
  private permissionSqlStatements: any = [];

  // DI
  private readonly config;
  private readonly logger: ILogger;

  constructor(
    @Inject((type) => BootLoader) bootLoader,
github fullstack-build / fullstack-one / packages / graphql / lib / index.ts View on Github external
import * as KoaRouter from 'koa-router';

import { getResolvers } from './queryBuilder/resolvers';

// fullstack-one core
import { Service, Inject, Container } from '@fullstack-one/di';
// DI imports
import { LoggerFactory, ILogger } from '@fullstack-one/logger';
import { Config, IEnvironment } from '@fullstack-one/config';
import { BootLoader } from '@fullstack-one/boot-loader';
import { GraphQlParser } from '@fullstack-one/graphql-parser';
import { helper } from '@fullstack-one/helper';
import { Server } from '@fullstack-one/server';
import { DbGeneralPool } from '@fullstack-one/db';

@Service()
export class GraphQl {

  private graphQlConfig: any;

  // DI
  private logger: ILogger;
  private ENVIRONMENT: IEnvironment;
  private gqlParser: GraphQlParser;
  private server: Server;
  private dbGeneralPool: DbGeneralPool;
  private resolvers: any = {};
  private customQueries: any = [];
  private customMutations: any = [];
  private customFields: any = {};

  private preQueryHooks = [];
github fullstack-build / fullstack-one / packages / server / lib / index.ts View on Github external
import { Service, Container, Inject } from "@fullstack-one/di";
import { Config, IEnvironment } from "@fullstack-one/config";
import { ILogger, LoggerFactory } from "@fullstack-one/logger";
import { BootLoader } from "@fullstack-one/boot-loader";
import { GracefulShutdown } from "@fullstack-one/graceful-shutdown";

import * as http from "http";
// other npm dependencies
import * as Koa from "koa";
import * as compress from "koa-compress";
import * as bodyParser from "koa-bodyparser";

export { Koa };

@Service()
export class Server {
  private serverConfig;
  private server: http.Server;
  private app: Koa;

  private loggerFactory: LoggerFactory;
  private logger: ILogger;
  private ENVIRONMENT: IEnvironment;
  private readonly bootLoader: BootLoader;
  // private eventEmitter: EventEmitter;

  constructor(
    // @Inject(type => EventEmitter) eventEmitter?,
    @Inject((type) => LoggerFactory) loggerFactory: LoggerFactory,
    @Inject((type) => Config) config: Config,
    @Inject((tpye) => BootLoader) bootLoader: BootLoader,
github fullstack-build / fullstack-one / packages / auth / lib / index.ts View on Github external
import { AuthProvider } from "./AuthProvider";
import { IAuthFactorForProof, IUserAuthentication, ILoginData } from "./interfaces";
import { CryptoFactory } from "./CryptoFactory";
import { SignHelper } from "./SignHelper";
import * as _ from "lodash";

const schema = fs.readFileSync(require.resolve("../schema.gql"), "utf-8");

export * from "./SignHelper";
export * from "./interfaces";
export * from "./AuthProviders/AuthProviderEmail";
export * from "./AuthProviders/AuthProviderOAuth";
export * from "./AuthProviders/AuthProviderPassword";
export { AuthProvider, IAuthFactorForProof };

@Service()
export class Auth {
  private authConfig;
  private cryptoFactory: CryptoFactory;
  private signHelper: SignHelper;
  private authQueryHelper: AuthQueryHelper;
  private csrfProtection: CSRFProtection;
  private accessTokenParser: AccessTokenParser;
  private orm: ORM;

  // DI
  private logger: ILogger;
  private loggerFactory: LoggerFactory;
  private userRegistrationCallback: (userAuthentication: IUserAuthentication) => void;

  public readonly authConnector: AuthConnector;
github fullstack-build / fullstack-one / packages / auth / lib / index.ts View on Github external
import * as koaSession from "koa-session";
import * as koaCors from "@koa/cors";
import oAuthCallback from "./oAuthCallback";
import { setDirectiveParser } from "./migrationHelper";
import { getParser } from "./getParser";
// import { DbGeneralPool } from '@fullstack-one/db/DbGeneralPool';

import * as fs from "fs";
import { URL } from "url";

const schema = fs.readFileSync(require.resolve("../schema.gql"), "utf-8");

// export
export * from "./signHelper";

@Service()
export class Auth {
  private sodiumConfig;
  private authConfig;
  private notificationFunction;
  private possibleTransactionIsolationLevels: [string, string, string, string] = [
    "SERIALIZABLE",
    "REPEATABLE READ",
    "READ COMMITTED",
    "READ UNCOMMITTED"
  ];

  // DI
  private config: Config;
  private dbGeneralPool: DbGeneralPool;
  private loggerFactory: LoggerFactory;
  private logger: ILogger;
github fullstack-build / fullstack-one / packages / db / lib / DAO / index.ts View on Github external
import * as massive from "massive";
import { Service, Inject, Container } from "@fullstack-one/di";

@Service()
export class DAO {
  constructor() {
    massive({
      host: "localhost",
      port: 5432,
      database: "fullstack-one-example",
      user: "postgres",
      password: ""
    }).then((db) => {
      console.log("****", db);
    });
  }
}
github fullstack-build / fullstack-one / packages / auth / lib / AuthProviders / AuthProviderOAuth.ts View on Github external
<h1>This Page requires Javascript.</h1>

`;

const oAuthCallback = (message, origins) =&gt; {
  const data = {
    message,
    origins
  };

  return template.replace("&lt;%=data%&gt;", JSON.stringify(data));
};

@Service()
export class AuthProviderOAuth {
  private emailAuthProvider: AuthProvider;
  private oAuthAuthProviders: { [key: string]: AuthProvider } = {};

  private server: Server;
  private logger: ILogger;
  private orm: ORM;

  private authConfig;

  constructor(
    @Inject((type) =&gt; SchemaBuilder) schemaBuilder: SchemaBuilder,
    @Inject((type) =&gt; GraphQl) graphQl: GraphQl,
    @Inject((type) =&gt; Auth) auth: Auth,
    @Inject((type) =&gt; ORM) orm: ORM,
    @Inject((type) =&gt; Server) server: Server,
github fullstack-build / fullstack-one / packages / queue / lib / index.ts View on Github external
import * as PgBoss from "pg-boss";
export { PgBoss };

import { BootLoader } from "@fullstack-one/boot-loader";
import { Config } from "@fullstack-one/config";
import { ORM } from "@fullstack-one/db";
import { GracefulShutdown } from "@fullstack-one/graceful-shutdown";
import { Service, Inject, Container } from "@fullstack-one/di";
import { ILogger, LoggerFactory } from "@fullstack-one/logger";

@Service()
export class QueueFactory {
  private queue: PgBoss;
  private readonly logger: ILogger;

  constructor(
    @Inject((type) => BootLoader) bootLoader: BootLoader,
    @Inject((type) => GracefulShutdown) gracefulShutdown: GracefulShutdown,
    @Inject((type) => LoggerFactory) loggerFactory: LoggerFactory,
    @Inject((type) => ORM) private readonly orm: ORM,
    @Inject((type) => Config) config: Config
  ) {
    config.registerConfig("Queue", `${__dirname}/../config`);
    this.logger = loggerFactory.create(this.constructor.name);

    bootLoader.addBootFunction(this.constructor.name, this.boot.bind(this));
    gracefulShutdown.addShutdownFunction(this.constructor.name, this.end.bind(this));
github fullstack-build / fullstack-one / packages / auto-migrate / lib / index.ts View on Github external
import { Service, Inject } from "@fullstack-one/di";
import { SchemaBuilder } from "@fullstack-one/schema-builder";
import { ILogger, LoggerFactory } from "@fullstack-one/logger";
import { BootLoader } from "@fullstack-one/boot-loader";

@Service()
export class AutoMigrate {
  private logger: ILogger;
  private schemaBuilder: SchemaBuilder;

  constructor(
    @Inject((type) => LoggerFactory) loggerFactory: LoggerFactory,
    @Inject((type) => BootLoader) bootLoader: BootLoader,
    @Inject((type) => SchemaBuilder) schemaBuilder: SchemaBuilder
  ) {
    this.schemaBuilder = schemaBuilder;
    this.logger = loggerFactory.create(this.constructor.name);

    bootLoader.addBootFunction(this.constructor.name, this.boot.bind(this));
  }

  public async boot() {
github fullstack-build / fullstack-one / packages / graceful-shutdown / lib / index.ts View on Github external
import { ILogger, LoggerFactory } from "@fullstack-one/logger";
import { BootLoader } from "@fullstack-one/boot-loader";
import { Config } from "@fullstack-one/config";

import * as exitHook from "async-exit-hook";
import * as terminus from "@godaddy/terminus";
import { IGracefulShutdownConfig } from "./IGracefulShutdownConfig";

type TShutdownFunction = () =&gt; Promise | void;

interface IShutdownItem {
  name: string;
  fn: TShutdownFunction;
}

@Service()
export class GracefulShutdown {
  private bootLoader: BootLoader;
  private logger: ILogger;
  private eventEmitter: EventEmitter;
  private readonly config: IGracefulShutdownConfig;

  private readonly shutdownItems: IShutdownItem[] = [];

  constructor(
    @Inject((type) =&gt; BootLoader) bootLoader: BootLoader,
    @Inject((type) =&gt; LoggerFactory) loggerFactory: LoggerFactory,
    @Inject((type) =&gt; EventEmitter) eventEmitter: EventEmitter,
    @Inject((type) =&gt; Config) config: Config
  ) {
    this.bootLoader = bootLoader;
    this.logger = loggerFactory.create(this.constructor.name);

@fullstack-one/di

fullstack.one helper package

MIT
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Similar packages