Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 {
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;
constructor() {
this.connection = this.connectionManager.create(connectionConfig);
this.accountsDatabase = new AccountsTypeorm({
connection: this.connection,
});
}
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) {