How to use @accounts/typeorm - 4 common examples

To help you get started, we’ve selected a few @accounts/typeorm 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 accounts-js / accounts / examples / graphql-server-typeorm-postgres / src / index.ts View on Github external
export const createAccounts = async () => {
  const connection = await connect(process.env.DATABASE_URL);
  // Like, fix this man!
  const tokenSecret = 'process.env.ACCOUNTS_SECRET' || 'change this in .env';
  const db = new AccountsTypeorm({ connection, cache: 1000 });
  const password = new AccountsPassword();
  const accountsServer = new AccountsServer(
    {
      db,
      tokenSecret,
      siteUrl: 'http://localhost:3000',
    },
    { password }
  );
  // Creates resolvers, type definitions, and schema directives used by accounts-js
  const accountsGraphQL = AccountsModule.forRoot({
    accountsServer,
  });

  const typeDefs = `
type PrivateType @auth {
github birkir / prime / packages / prime-core / src / utils / connect.ts View on Github external
export const connect = (url = process.env.DATABASE_URL) => {
  const ssl = Boolean(
    String(url).indexOf('ssl=true') >= 0 || String(url).indexOf('amazonaws.com') >= 0
  );
  pg.defaults.ssl = ssl;

  return createConnection({
    type: 'postgres',
    url,
    entities: [
      ...require('@accounts/typeorm').entities,
      path.join(__dirname, '..', 'entities', '*.ts'),
      path.join(__dirname, '..', 'entities', '*.js'),
    ],
    ssl,
    synchronize: true,
    logger: 'debug',
  }).then(connection => {
    const driver = connection.driver as PostgresDriver;

    // Fixes postgres timezone bug
    if (driver.postgres) {
      driver.postgres.defaults.parseInputDatesAsUTC = true;
      driver.postgres.types.setTypeParser(1114, (str: any) => new Date(str + 'Z'));
    }

    return connection;
github accounts-js / accounts / packages / e2e / __tests__ / databases / typeorm.ts View on Github external
constructor() {
    this.connection = this.connectionManager.create(connectionConfig);
    this.accountsDatabase = new AccountsTypeorm({
      connection: this.connection,
    });
  }
github birkir / prime / packages / prime-core / src / modules / accounts / index.ts View on Github external
export const createAccounts = async (connection: Connection) => {
  const tokenSecret = ACCOUNTS_SECRET || 'not very secret secret';
  const db = new AccountsTypeorm({
    connection,
    cache: 1000,
  });

  const password = new AccountsPassword({
    twoFactor: {
      appName: 'Prime',
    },
  });

  const accountsServer = new AccountsServer(
    {
      db,
      tokenSecret,
      siteUrl: CORE_URL,
      sendMail(mail) {

@accounts/typeorm

TypeORM adaptor for accounts

MIT
Latest version published 8 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages