Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft : Logging and Country of Query #70

Merged
merged 10 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export COUNTRY_OF_QUERY=IN
export LOGGING=true
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache Node.js dependencies
uses: actions/cache@v3
Expand All @@ -25,7 +25,7 @@ jobs:
${{ runner.os }}-npm-

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down Expand Up @@ -54,10 +54,10 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Log into GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:

steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get FlyCtl
uses: superfly/flyctl-actions/setup-flyctl@master
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/newman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ jobs:
newman:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Check out repository code and Install
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: npm install
- run: npm run generateoas
- run: npm start & npx wait-on http://localhost:3000
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
- run: npm ci

publish-gpr:
Expand All @@ -25,10 +25,10 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
registry-url: https://npm.pkg.github.com/

- name: Install dependencies
Expand Down
6 changes: 5 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

tasks:
- name: Setup and Install
before: npm install
before: |
nvm install 18
nvm use 18
npm install
source .env.sample
init: npm run generateoas
command: npm run start

Expand Down
5 changes: 4 additions & 1 deletion Spacefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ micros:
env:
- name: COUNTRY_OF_QUERY
description: Country parameter to be defaulted for all requests
default: "US"
default: "US"
- name: LOGGING
description: Sets LOGGING
default: "false"
10 changes: 10 additions & 0 deletions fly.production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ primary_region = "sin"
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[http_service.concurrency]
type = "requests"
soft_limit = 200
hard_limit = 250

[[services.ports]]
handlers = ["http"]
port = 80
force_https = true # optional

[env]
COUNTRY_OF_QUERY = "IN"
LOGGING = true
10 changes: 10 additions & 0 deletions fly.staging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ primary_region = "sin"
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[http_service.concurrency]
type = "requests"
soft_limit = 200
hard_limit = 250

[[services.ports]]
handlers = ["http"]
port = 80
force_https = true # optional


[env]
COUNTRY_OF_QUERY = "IN"
Expand Down
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ const router = Express.Router();

const toList = (apps) => ({ results: apps });


router.use((req, res, next) => {

if (!req.query.country) {
req.query.country = process.env.COUNTRY_OF_QUERY || 'US';;
}

if (process.env.LOGGING || false) {
console.log("GPlayAPI", req.url, req.baseUrl, req.params)
}

next();
});

Expand Down Expand Up @@ -260,4 +263,4 @@ function errorHandler(err, req, res, next) {

router.use(errorHandler);

export default router;
export default router;
Loading
Loading