3 const DB
= require('../src/db');
4 const Logger
= require('../src/logger');
5 const Config
= require('../config');
6 const config
= new Config(process
.env
.NODE_ENV
);
8 const logger
= new Logger(config
);
9 const db
= new DB(logger
, config
);
12 const identifier
= process
.argv
[2];
13 const profile
= process
.argv
[3];
16 console
.log('missing user');
17 throw new Error('missing argument');
20 console
.log('missing profile');
21 throw new Error('missing argument');
25 await db
.initialize();
26 await db
.context(async (dbCtx
) => {
27 const user
= await db
.authenticationGet(dbCtx
, identifier
);
29 console
.log('user does not exist');
30 throw new Error('invalid identifier');
32 const profileURL
= new URL(profile
); // Validate and normalize
33 const result
= await db
.profileIdentifierInsert(dbCtx
, profileURL
.href
, identifier
);
37 await db
._closeConnection();