-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Cavdy/api
Api
- Loading branch information
Showing
38 changed files
with
1,415 additions
and
771 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env" | ||
"presets": [ | ||
"@babel/preset-env" | ||
], | ||
"plugins": [ | ||
[ | ||
"@babel/plugin-transform-runtime", | ||
{ | ||
"absoluteRuntime": false, | ||
"corejs": false, | ||
"helpers": true, | ||
"regenerator": true, | ||
"useESModules": false | ||
} | ||
] | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[Dolphin] | ||
Timestamp=2019,4,17,3,23,17 | ||
Version=4 | ||
|
||
[Settings] | ||
HiddenFilesShown=true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
id | email | firstname | lastname | accountnumber | createdon | owner | type | status | balance | ||
----+---------------------+-----------+----------+---------------+-----------+-------+---------+---------+--------- | ||
1 | banka872@banka4.com | | | 3702581476 | 17/4/2019 | 50 | savings | active | 0 | ||
2 | banka872@banka4.com | | | 3872146107 | 17/4/2019 | 50 | savings | active | 0 | ||
5 | banka872@banka4.com | cavdy | isaiah | 3548652217 | 17/4/2019 | 50 | savings | active | 0 | ||
6 | banka872@banka4.com | cavdy | isaiah | 3491564558 | 17/4/2019 | 50 | savings | active | 0 | ||
7 | banka872@banka4.com | cavdy | isaiah | 3146859791 | 17/4/2019 | 54 | savings | active | 0 | ||
8 | banka872@banka4.com | cavdy | isaiah | 3779533562 | 17/4/2019 | 55 | savings | active | 0 | ||
3 | banka872@banka4.com | cavdy | isaiah | 3699742813 | 17/4/2019 | 50 | savings | dormant | 0 | ||
10 | banka872@banka4.com | cavdy | isaiah | 3484311663 | 17/4/2019 | 57 | savings | active | 0 | ||
11 | banka872@banka4.com | cavdy | isaiah | 3204762909 | 17/4/2019 | 57 | savings | active | 0 | ||
12 | banka872@banka4.com | cavdy | isaiah | 3877851924 | 17/4/2019 | 59 | savings | active | 0 | ||
13 | banka872@banka4.com | cavdy | isaiah | 3072181085 | 17/4/2019 | 60 | savings | active | 0 | ||
14 | banka872@banka4.com | cavdy | isaiah | 3432650514 | 17/4/2019 | 60 | savings | active | 0 | ||
15 | banka872@banka4.com | cavdy | isaiah | 3983443368 | 17/4/2019 | 61 | savings | active | 0 | ||
16 | banka872@banka4.com | cavdy | isaiah | 3438930243 | 17/4/2019 | 61 | savings | active | 0 | ||
17 | banka872@banka4.com | cavdy | isaiah | 3655609161 | 17/4/2019 | 62 | savings | active | 0 | ||
18 | banka872@banka4.com | cavdy | isaiah | 3297739483 | 17/4/2019 | 62 | savings | active | 0 | ||
19 | banka872@banka4.com | cavdy | isaiah | 3633960829 | 17/4/2019 | 62 | savings | active | 0 | ||
20 | banka872@banka4.com | cavdy | isaiah | 3003801983 | 17/4/2019 | 63 | savings | active | 0 | ||
21 | banka872@banka4.com | cavdy | isaiah | 3453420061 | 17/4/2019 | 63 | savings | active | 0 | ||
22 | banka872@banka4.com | cavdy | isaiah | 3797532048 | 17/4/2019 | 63 | savings | active | 0 | ||
23 | admin@banka.com | cavdy | ikenna | 3515833161 | 17/4/2019 | 64 | savings | active | 0 | ||
24 | banka872@banka4.com | cavdy | isaiah | 3931715014 | 17/4/2019 | 65 | savings | active | 0 | ||
25 | banka872@banka4.com | cavdy | isaiah | 3502561578 | 17/4/2019 | 65 | savings | active | 0 | ||
26 | banka872@banka4.com | cavdy | isaiah | 3261422912 | 17/4/2019 | 65 | savings | active | 0 | ||
27 | banka872@banka4.com | cavdy | isaiah | 3298245957 | 17/4/2019 | 67 | savings | active | 0 | ||
28 | banka872@banka4.com | cavdy | isaiah | 3461967601 | 17/4/2019 | 67 | savings | active | 0 | ||
29 | banka872@banka4.com | cavdy | isaiah | 3243384247 | 17/4/2019 | 67 | savings | active | 0 | ||
30 | admin@banka.com | cavdy | ikenna | 3563254210 | 17/4/2019 | 68 | savings | active | 0 | ||
31 | banka872@banka4.com | cavdy | isaiah | 3534066798 | 17/4/2019 | 69 | savings | active | 0 | ||
32 | banka872@banka4.com | cavdy | isaiah | 3482397810 | 17/4/2019 | 69 | savings | active | 0 | ||
33 | banka872@banka4.com | cavdy | isaiah | 3110547517 | 17/4/2019 | 69 | savings | active | 0 | ||
34 | banka872@banka4.com | cavdy | isaiah | 3437719577 | 17/4/2019 | 69 | savings | active | 0 | ||
35 | banka872@banka4.com | cavdy | isaiah | 3548538073 | 17/4/2019 | 71 | savings | active | 0 | ||
36 | banka872@banka4.com | cavdy | isaiah | 3703724774 | 17/4/2019 | 73 | savings | active | 0 | ||
37 | banka872@banka4.com | cavdy | isaiah | 3124616562 | 17/4/2019 | 75 | savings | active | 0 | ||
38 | banka872@banka4.com | cavdy | isaiah | 3057087124 | 17/4/2019 | 77 | savings | active | 0 | ||
39 | banka872@banka4.com | cavdy | isaiah | 3753591929 | 17/4/2019 | 79 | savings | active | 0 | ||
40 | banka872@banka4.com | cavdy | isaiah | 3008302349 | 17/4/2019 | 81 | savings | active | 0 | ||
41 | banka872@banka4.com | cavdy | isaiah | 3164295216 | 17/4/2019 | 83 | savings | active | 0 | ||
42 | banka872@banka4.com | cavdy | isaiah | 3355341006 | 17/4/2019 | 85 | savings | active | 0 | ||
43 | banka872@banka4.com | cavdy | isaiah | 3043952815 | 17/4/2019 | 87 | savings | active | 0 | ||
44 | banka872@banka4.com | cavdy | isaiah | 3331809305 | 17/4/2019 | 89 | savings | active | 0 | ||
45 | banka872@banka4.com | cavdy | isaiah | 3983804072 | 17/4/2019 | 91 | savings | active | 0 | ||
46 | banka872@banka4.com | cavdy | isaiah | 3446930353 | 17/4/2019 | 93 | savings | active | 0 | ||
47 | banka872@banka4.com | cavdy | isaiah | 3571949659 | 17/4/2019 | 95 | savings | active | 0 | ||
48 | banka872@banka4.com | cavdy | isaiah | 3242133029 | 17/4/2019 | 97 | savings | active | 0 | ||
49 | banka872@banka4.com | cavdy | isaiah | 3384304769 | 17/4/2019 | 107 | savings | active | 0 | ||
50 | banka872@banka4.com | cavdy | isaiah | 3429391534 | 17/4/2019 | 107 | savings | active | 0 | ||
51 | banka872@banka4.com | cavdy | isaiah | 3344395362 | 17/4/2019 | 107 | savings | active | 0 | ||
(49 rows) | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- Accounts SQL query | ||
|
||
-- create accounts table | ||
CREATE TABLE accounts ( | ||
id SERIAL PRIMARY KEY UNIQUE, | ||
email VARCHAR(80), | ||
firstName VARCHAR(20), | ||
lastName VARCHAR(20), | ||
accountNumber BIGINT UNIQUE, | ||
createdOn VARCHAR(40), | ||
owner INTEGER, | ||
type VARCHAR(10), | ||
status VARCHAR(10), | ||
balance FLOAT | ||
); | ||
|
||
-- select all from accounts table | ||
SELECT * FROM accounts LIMIT 10 | ||
|
||
-- select account number fro accounts | ||
SELECT accountNumber FROM accounts WHERE accountNumber=$1, ['accountNumber'] | ||
|
||
-- insert into accounts table | ||
INSERT into accounts values($1), ['value'] | ||
|
||
-- delete from accounts table | ||
DELETE FROM accounts; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Pool } from 'pg'; | ||
import debug from 'debug'; | ||
import dotenv from 'dotenv'; | ||
import { parse } from 'pg-connection-string'; | ||
|
||
dotenv.config(); | ||
|
||
const conString = parse(process.env.DB_CONFIG); | ||
|
||
const pool = new Pool(conString); | ||
|
||
const dbConnection = { | ||
async dbConnect(passedQuery, passedData) { | ||
try { | ||
return (async () => { | ||
const client = await pool.connect(); | ||
try { | ||
return await client.query(passedQuery, passedData); | ||
} finally { | ||
client.release(); | ||
} | ||
})(); | ||
} catch (e) { | ||
return debug('query')(e.stack); | ||
} | ||
}, | ||
async dbTesting(passedQuery) { | ||
try { | ||
return (async () => { | ||
const client = await pool.connect(); | ||
try { | ||
return await client.query(passedQuery); | ||
} finally { | ||
client.release(); | ||
} | ||
})(); | ||
} catch (e) { | ||
return debug('query')(e.stack); | ||
} | ||
}, | ||
}; | ||
|
||
export default dbConnection; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- Transactions SQL query | ||
|
||
-- create transactions table | ||
CREATE TABLE transactions ( | ||
id SERIAL PRIMARY KEY UNIQUE, | ||
createdOn VARCHAR(40), | ||
type VARCHAR(10), | ||
accountNumber BIGINT, | ||
cashier INTEGER, | ||
amount FLOAT, | ||
oldBalance FLOAT, | ||
newBalance FLOAT | ||
); | ||
|
||
-- select all from transactions table | ||
SELECT * FROM transactions LIMIT 10 | ||
|
||
-- select account number fro transactions | ||
SELECT accountNumber FROM transactions WHERE accountNumber=$1, ['accountNumber'] | ||
|
||
-- insert into transactions table | ||
INSERT into transactions values($1), ['value'] | ||
|
||
-- update | ||
UPDATE transactions SET balance=$1 WHERE accountnumber=$2, [newBalance, accountNumber] | ||
|
||
-- delete from transactions table | ||
DELETE FROM transactions; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- Users SQL query | ||
|
||
-- create users table | ||
CREATE TABLE users ( | ||
id SERIAL PRIMARY KEY UNIQUE, | ||
email VARCHAR(80) UNIQUE, | ||
firstName VARCHAR(20), | ||
lastName VARCHAR(20), | ||
password VARCHAR(80), | ||
type VARCHAR(10), | ||
isAdmin BOOLEAN | ||
); | ||
|
||
-- select all from users table | ||
SELECT * FROM users LIMIT 10 | ||
|
||
-- select email fro users | ||
SELECT email FROM users WHERE email=$1, ['email'] | ||
|
||
-- insert into users table | ||
INSERT into users values($1), ['value'] | ||
|
||
-- delete from users table | ||
DELETE FROM users; | ||
|
||
-- admin | ||
INSERT into users(email, firstName, lastName, password, type, isAdmin) values('admin@banka.com', 'cavdy', 'ikenna', '$2a$10$CmmIst1.D3QjaWuafKbBaOuAFu0r9o7xxQY.0SMKiAN.h9z52a2y2', 'staff', true) |
Oops, something went wrong.