Skip to content

Commit

Permalink
Merge pull request #66 from Codykilpatrick/feat/support-local-develop…
Browse files Browse the repository at this point in the history
…ment

feat: support local development
  • Loading branch information
Codykilpatrick authored Nov 8, 2023
2 parents b590e4c + 2adc621 commit 0e570e0
Show file tree
Hide file tree
Showing 6 changed files with 373 additions and 21 deletions.
9 changes: 5 additions & 4 deletions packages/celestia-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Celestia API package

# Usage
## Usage

`npm install`
`npm start`
`npm run dev`

Navigate to:
http://localhost:8080/graphiql
<http://localhost:8080/graphiql>

To play with the browser graphql interface
To play with the browser graphql interface
3 changes: 2 additions & 1 deletion packages/celestia-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"test": "test",
"start": "node src/index.js",
"start": "NODE_ENV=production node src/index.js",
"dev": "NODE_ENV=development node src/index.js",
"build": "echo 'No build step required'",
"watch": "nodemon src/index.js"
},
Expand Down
28 changes: 22 additions & 6 deletions packages/celestia-api/src/postgraphile.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
const { postgraphile } = require('postgraphile')

const { DATABASE, NEON_USER, NEON_PASSWORD, NEON_HOST, NEON_PORT } = process.env
const { DATABASE, NEON_USER, NEON_PASSWORD, NEON_HOST, NEON_PORT, NODE_ENV } = process.env

module.exports = postgraphile(
{
let databaseConfig;


if (NODE_ENV === 'development') {
databaseConfig = {
database: 'celestia',
user: 'postgres',
password: 'password',
host: '127.0.0.1',
port: '5432',
};
} else if (NODE_ENV === 'production') {
databaseConfig = {
database: DATABASE,
user: NEON_USER,
password: NEON_PASSWORD,
host: NEON_HOST,
port: NEON_PORT,
ssl: require,
},
};
}


module.exports = postgraphile(
databaseConfig,
'celestia_public',
{
watchPg: false,
Expand All @@ -20,5 +36,5 @@ module.exports = postgraphile(
dynamicJson: true,
exportGqlSchemaPath: `${__dirname}/schema.graphql`,
retryOnInitFail: false
},
)
}
);
Loading

0 comments on commit 0e570e0

Please sign in to comment.