Skip to content

Commit

Permalink
Add dotenv to configure port
Browse files Browse the repository at this point in the history
  • Loading branch information
666lcz committed Mar 6, 2022
1 parent a47de6e commit a71f78f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
5 changes: 5 additions & 0 deletions nft_mirror/oracle_server/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Set to production when deploying to production
NODE_ENV=development

# Node.js server configuration
SERVER_PORT=8000
5 changes: 1 addition & 4 deletions nft_mirror/oracle_server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
/build

# misc
.env.local
.env.development.local
.env.test.local
.env.production.local
.env

npm-debug.log*
yarn-debug.log*
Expand Down
9 changes: 8 additions & 1 deletion nft_mirror/oracle_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ As shown in the graph below, the main job of the oracle is to validate the user

![user flow](./docs/flow.png 'User Flow')

## Development
## Get Started

1. Set up the `.env` file through `cp .env.sample .env`
2. Install the dependencies through `npm i`
3. Start the server through `npm run dev`
4. The easiest way to test out an endpoint is through [http://localhost:8000/docs](http://localhost:8000/docs) by clicking on "Try it out". No need to manually write curl command or example data.

## Useful Commands for Development

**Requirements**: Node 14.0.0 or later version

Expand Down
34 changes: 34 additions & 0 deletions nft_mirror/oracle_server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions nft_mirror/oracle_server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"description": "",
"devDependencies": {
"@types/body-parser": "^1.19.2",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.13",
"@types/morgan": "^1.9.3",
"@types/node": "^17.0.21",
Expand All @@ -43,6 +44,7 @@
},
"dependencies": {
"body-parser": "^1.19.2",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"morgan": "^1.10.0",
"swagger-ui-express": "^4.3.0",
Expand Down
4 changes: 4 additions & 0 deletions nft_mirror/oracle_server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import morgan from 'morgan';
import bodyParser from 'body-parser';
import { RegisterRoutes } from '../build/routes';
import swaggerUi from 'swagger-ui-express';
import dotenv from 'dotenv';

// initialize configuration
dotenv.config();

const PORT = process.env.PORT || 8000;

Expand Down

0 comments on commit a71f78f

Please sign in to comment.