-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,240 additions
and
8 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 |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
- uses: akhileshns/[email protected] | ||
with: | ||
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | ||
heroku_app_name: ${{secrets.HEROKU_APP_NAME}} | ||
heroku_app_name: ${{secrets.HEROKU_ANALYTICS_APP_NAME}} | ||
heroku_email: ${{secrets.HEROKU_EMAIL}} | ||
usedocker: true | ||
appdir: "analytics" |
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,19 @@ | ||
name: Deploy API to Heroku | ||
|
||
on: | ||
push: | ||
branches: | ||
- prod | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: akhileshns/[email protected] | ||
with: | ||
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | ||
heroku_app_name: ${{secrets.HEROKU_API_APP_NAME}} | ||
heroku_email: ${{secrets.HEROKU_EMAIL}} | ||
usedocker: true | ||
appdir: "api" |
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,6 @@ | ||
# Local development | ||
POSTGRES_USER=postgres | ||
POSTGRES_HOST=localhost | ||
POSTGRES_DB=postgres | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_PORT=5432 |
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,29 @@ | ||
# dev | ||
.yarn/ | ||
!.yarn/releases | ||
.vscode/* | ||
!.vscode/launch.json | ||
!.vscode/*.code-snippets | ||
.idea/workspace.xml | ||
.idea/usage.statistics.xml | ||
.idea/shelf | ||
|
||
# deps | ||
node_modules/ | ||
dist | ||
|
||
# env | ||
.env | ||
.env.production | ||
|
||
# logs | ||
logs/ | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
# misc | ||
.DS_Store |
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,18 @@ | ||
FROM oven/bun:1 as base | ||
WORKDIR /app | ||
|
||
# Install dependencies only | ||
FROM base AS deps | ||
COPY package.json . | ||
RUN bun install --frozen-lockfile | ||
|
||
# Production image | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
ENTRYPOINT [ "/app/heroku-run.sh" ] | ||
CMD ["bun", "run", "src/index.ts"] | ||
|
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,24 @@ | ||
# Cowllector API | ||
|
||
## Development | ||
|
||
```bash | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
The server will start at http://localhost:3000 | ||
|
||
## API Documentation | ||
|
||
OpenAPI documentation is available at: http://localhost:3000/api/docs | ||
Swagger UI is available at: http://localhost:3000/swagger | ||
|
||
## Test URLs for Last Harvest Reports Endpoint | ||
|
||
``` | ||
# Get all last harvest reports | ||
http://localhost:3000/api/v1/last-harvest-reports | ||
``` | ||
|
||
You can test this URL in your browser or using tools like curl or Postman. The API will return a JSON response with an array containing the last harvest report for each vault. |
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,30 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", | ||
"vcs": { | ||
"enabled": false, | ||
"clientKind": "git", | ||
"useIgnoreFile": false | ||
}, | ||
"files": { | ||
"ignoreUnknown": false, | ||
"ignore": [] | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"indentStyle": "tab" | ||
}, | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "double" | ||
} | ||
} | ||
} |
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,20 @@ | ||
#!/bin/bash -e | ||
|
||
# use a pointer to the environment variable because it may change name | ||
DB_URL=${!COWLLECTOR_DB_URL_ENV_VAR} | ||
|
||
[[ $DB_URL =~ ^postgres:\/\/([^:]+):([^@]+)@([^:]+):([^\/]+)\/(.+)$ ]] | ||
export PG_USERNAME="${BASH_REMATCH[1]}" | ||
export PG_PASSWORD="${BASH_REMATCH[2]}" | ||
export PG_HOSTNAME="${BASH_REMATCH[3]}" | ||
export PG_PORT="${BASH_REMATCH[4]}" | ||
export PG_DATABASE="${BASH_REMATCH[5]}" | ||
|
||
if [[ -z "$PG_USERNAME" || -z "$PG_PASSWORD" || -z "$PG_HOSTNAME" || -z "$PG_PORT" || -z "$PG_DATABASE" ]]; then | ||
echo "Invalid DATABASE_URL: $DB_URL" | ||
echo "Found looking at the content of '$COWLLECTOR_DB_URL_ENV_VAR'" | ||
echo "Expected format: postgres://username:password@hostname:port/database" | ||
exit 1 | ||
fi | ||
|
||
exec "$@" |
Oops, something went wrong.