This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createNewAccount = async (params) => { | |
if (!params.username) { | |
throw new Error('Missing required username'); | |
} | |
if (!params.email) { | |
throw new Error ('Missing required email'); | |
} | |
if (params.username.length > 25) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { validateParameters } from './utils'; | |
import { checkUsernameExists, checkEmailExists } from './users'; | |
import { insertUser } from './users/db'; | |
export const createNewAccount = async (params) => { | |
await validateParameters(params); | |
await checkUsernameExists(params.username); | |
await checkEmailExists(params.email); | |
return insertUser(params); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import db from 'db'; | |
export const checkUsernameExists = username => { | |
const user = db.select('id') | |
->from('users') | |
->where('username', username) | |
->first(); | |
return Object.keys(user).length > 0; | |
// returns boolean true | false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import db from 'Db'; | |
export const checkUsernameExists = username => { | |
return db.select('*') | |
->from('users') | |
->where('username', username) | |
->first(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import db from 'Db'; | |
export const getUserById = id => { | |
return db.select('username,email') | |
->from('users') | |
->where('id', id) | |
->first(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import db from 'Db'; | |
export const getUserById = id => { | |
return db.select('*') | |
->from('users') | |
->where('id', id) | |
->first(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { gtU } from 'Models/User'; | |
// Get User object by id | |
const u = gtU(123); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getUserById } from 'Models/User'; | |
const user = getUserById(123); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
$config = [ | |
'AppKey' => '', // Get from VBC | |
'SecretKey' => '', // Get from VBC | |
'Version' => 'V2' | |
]; | |
// instantiate the required objects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
$config = [ | |
'AppKey' => '', // Get from VBC | |
'SecretKey' => '', // Get from VBC | |
'Version' => 'V2' | |
]; | |
// instantiate the required objects |