-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(endpoints): secure all endpoints with jwt token
- create scripts to create db tables on local and production environment
- Loading branch information
Showing
8 changed files
with
180 additions
and
108 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
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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pool from '../models/pool'; | ||
import { dev_logger, test_logger } from './loggers'; | ||
|
||
console.log("CREATING TALBES") | ||
|
||
import { | ||
createUserTable, | ||
createLoansTable, | ||
createRepaymentsTable, | ||
} from './dbOps'; | ||
|
||
const queries = [ | ||
createUserTable, createLoansTable, createRepaymentsTable, | ||
]; | ||
|
||
export const createTables = async () => { | ||
for (const query of queries) { | ||
dev_logger(query); | ||
test_logger(query); | ||
await pool.query(query); | ||
} | ||
}; | ||
|
||
createTables(); | ||
console.log('TABLES CREATED') | ||
export default createTables; |
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,36 @@ | ||
import pool from '../models/pool'; | ||
import { dev_logger, test_logger } from './loggers'; | ||
|
||
import { | ||
createUserTable, | ||
populateUserTable, | ||
createLoansTable, | ||
populateLoansTable, | ||
createRepaymentsTable, | ||
populateRepaymentsTable, | ||
dropUsers, | ||
dropLoans, | ||
dropRepayments | ||
} from './dbOps'; | ||
|
||
const setup = [ | ||
createUserTable, createLoansTable, createRepaymentsTable, | ||
populateUserTable, populateLoansTable, populateRepaymentsTable | ||
]; | ||
|
||
const cleanup = [ dropUsers, dropLoans, dropRepayments ]; | ||
|
||
export const createDB = async () => { | ||
for (const query of setup) { | ||
dev_logger(query); | ||
test_logger(query); | ||
await pool.query(query); | ||
} | ||
}; | ||
|
||
export const clearDB = async () => { | ||
for (const query of cleanup) { | ||
dev_logger(query); | ||
await pool.query(query); | ||
} | ||
}; |