-
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.
Merge pull request #1 from muhsinkamil/initial-setup
Initial setup
- Loading branch information
Showing
11 changed files
with
2,545 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.env |
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,3 @@ | ||
BASE_PATH=http://localhost:3000 | ||
APP_PORT=3000 | ||
ENVIRONMENT=development |
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,14 @@ | ||
import { Knex } from "knex"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex.schema.createTable("users", (table) => { | ||
table.increments(); | ||
table.string("first_name"); | ||
table.string("last_name"); | ||
table.timestamps(true, true); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex.schema.dropTableIfExists("users"); | ||
} |
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 @@ | ||
// Update with your config settings. Made with command "knex init -x ts" | ||
|
||
export default { | ||
development: { | ||
client: "postgresql", | ||
connection: { | ||
database: "graphql_typed_db", | ||
user: "graphql_typed_user", | ||
password: "graphql_typed_password", | ||
}, | ||
pool: { | ||
min: 2, | ||
max: 10, | ||
}, | ||
migrations: { | ||
directory: "./db/migrations", | ||
}, | ||
}, | ||
|
||
staging: { | ||
client: "postgresql", | ||
connection: { | ||
database: "my_db", | ||
user: "username", | ||
password: "password", | ||
}, | ||
pool: { | ||
min: 2, | ||
max: 10, | ||
}, | ||
migrations: { | ||
directory: "./db/migrations", | ||
// tableName: "knex_migrations", | ||
}, | ||
}, | ||
|
||
production: { | ||
client: "postgresql", | ||
connection: { | ||
database: "my_db", | ||
user: "username", | ||
password: "password", | ||
}, | ||
pool: { | ||
min: 2, | ||
max: 10, | ||
}, | ||
migrations: { | ||
directory: "./db/migrations", | ||
// tableName: "knex_migrations", | ||
}, | ||
}, | ||
}; |
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,11 @@ | ||
import Knex from "knex"; | ||
import { Model } from "objection"; | ||
import { Environment } from "types"; | ||
import knexConfig from "../knexfile"; | ||
|
||
const setUpDb = (environment: Environment) => { | ||
const knex = Knex(knexConfig[environment]); | ||
Model.knex(knex); | ||
}; | ||
|
||
export default setUpDb; |
Oops, something went wrong.