Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
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 = [];
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,
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;
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;
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);
});
}
}
<h1>This Page requires Javascript.</h1>
`;
const oAuthCallback = (message, origins) => {
const data = {
message,
origins
};
return template.replace("<%=data%>", 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) => SchemaBuilder) schemaBuilder: SchemaBuilder,
@Inject((type) => GraphQl) graphQl: GraphQl,
@Inject((type) => Auth) auth: Auth,
@Inject((type) => ORM) orm: ORM,
@Inject((type) => Server) server: Server,
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));
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() {
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 = () => 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) => BootLoader) bootLoader: BootLoader,
@Inject((type) => LoggerFactory) loggerFactory: LoggerFactory,
@Inject((type) => EventEmitter) eventEmitter: EventEmitter,
@Inject((type) => Config) config: Config
) {
this.bootLoader = bootLoader;
this.logger = loggerFactory.create(this.constructor.name);