Skip to content

Commit

Permalink
removed test file
Browse files Browse the repository at this point in the history
  • Loading branch information
iangeckeler committed Jul 9, 2019
1 parent e30f3e0 commit f959f47
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
16 changes: 8 additions & 8 deletions functions/databases/mongoose/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ function create(userID, phone) {
const { client, TwoAuthUser, appName } = this;

return new Promise((resolve, reject) => {
if (typeof phone !== 'string') {
reject(new Error('typeof phone must be string'));
if (typeof phone !== "string") {
reject(new Error("typeof phone must be string"));
}
if (phone.substring(0, 2) !== '+1') {
reject(new Error('phone must be string formatted as such: +1XXXXXXXXXX'));
if (phone.substring(0, 2) !== "+1") {
reject(new Error("phone must be string formatted as such: +1XXXXXXXXXX"));
}
client.verify.services
.create({ friendlyName: `${appName}` })
.then((service) => {
.then(service => {
const { sid } = service;
TwoAuthUser.create({
userID,
sid,
phone,
phone
})
.then((user) => {
.then(user => {
resolve(user);
})
.catch((err) => {
.catch(err => {
reject(err);
});
})
Expand Down
42 changes: 21 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,26 @@ const postgresCreate = require("./functions/databases/postgres/create");
const postgresSend = require("./functions/databases/postgres/send");
const postgresVerify = require("./functions/databases/postgres/verify");

const connect = (AccSID, AuthToken, mongoURI = null) => {
return new Client(AccSID, AuthToken, mongoURI);
const connect = (
AccSID,
AuthToken,
options = {
appName: "",
connectionURI: null,
isPostgres: false
}
) => {
if (typeof options === "string")
throw new Error(
"Options config must be an object, as specified in the documentation."
);
if (!options.hasOwnProperty("isPostgres")) {
options.isPostgres = false;
}
if (!options.hasOwnProperty("appName")) {
options.appName = "";
}
return new Client(AccSID, AuthToken, options);
};

// EXAMPLE CONFIG OBJECT
Expand All @@ -29,25 +47,7 @@ const connect = (AccSID, AuthToken, mongoURI = null) => {
// isPostgres: null
// }
class Client {
constructor(
AccSID,
AuthToken,
options = {
appName: "",
connectionURI: null,
isPostgres: false
}
) {
if (typeof options === "string")
throw new Error(
"Options config must be an object, as specified in the documentation."
);
if (!options.hasOwnProperty("isPostgres")) {
options.isPostgres = false;
}
if (!options.hasOwnProperty("appName")) {
options.appName = "";
}
constructor(AccSID, AuthToken, options) {
this.appName = options.appName;
this.AccSID = AccSID;
this.AuthToken = AuthToken;
Expand Down

0 comments on commit f959f47

Please sign in to comment.