Skip to content

Commit

Permalink
Merge pull request #1 from westerandr/feat/show-site-stats
Browse files Browse the repository at this point in the history
Latency Stats & Test, Add Contribution, License and GitHub Workflow
  • Loading branch information
westerandr authored Aug 1, 2023
2 parents c8316af + 4c153c4 commit b27cff4
Show file tree
Hide file tree
Showing 11 changed files with 649 additions and 14 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Prepare for Production
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
runner:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm ci
- name: Run Tests
run: npm run test
- name: Build
run: npm run build
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via [issues](https://github.com/westerandr/govt-site-checker/issues), [discord](https://discord.gg/FJB4UQJwfV).

Please note if you are working on a certain issue then make sure to stay active with development.

## Git Commit, Branch, and PR Naming Conventions

When you are working with git, please be sure to follow the conventions below on your pull requests, branches, and commits:

```text
PR: [#ISSUE ID] Title of the PR
Branch: [ISSUE ID]-title-of-the-pr (shorter)
Commit: [[ISSUE ID]] [ACTION]: what was done
```

Examples:

```text
PR: #2 Add Docker container for Postgres
Branch: 2-add-container-postgres
Commit: [2] feat: add docker container for postgres
```
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Andre Westerlund

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Samoa Government Sites Checker

Checks the online statuses of Samoan government websites.
Checks the online availability of Samoan government and related association websites.

![image](https://github.com/westerandr/govt-site-checker/assets/20700150/7d4c17a3-fb9f-4741-9c06-fb8a2bec8e5b)


## List of Government Ministries

* Samoa Public Service Commission
Expand Down Expand Up @@ -48,6 +47,37 @@ Checks the online statuses of Samoan government websites.
* Unit Trust of Samoa
* Central Bank of Samoa

## Technology

* Astro Web Framework
* React
* Netlify Functions
* Tailwind CSS

## Roadmap

* Add E2E Tests
* Add Latency
* Sort List Items dynamically i.e. shuffle offline sites to the top
* Show iframe of website on hover

## Contribution

We welcome contributions from the community! If you'd like to contribute to the Samoa Govt Site Checker, please follow refer to [CONTRIBUTING.md](./CONTRIBUTING.md), but we have these base guidelines:

* Fork the repository.
* Create a new branch for your feature or bug fix.
* Make your changes and test thoroughly.
* Commit your changes with clear commit messages.
* Push your branch to your forked repository.
* Submit a pull request detailing your changes.

Please ensure that your code adheres to the project's coding standards and conventions.

## License

The Samoa Govt Site Checker is licensed under the MIT License. Feel free to use, modify, and distribute the code as per the terms of the license.

## Missing your website?

Open an issue or contact <[email protected]>
Expand Down
13 changes: 9 additions & 4 deletions netlify/functions/ping.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Handler, HandlerEvent, HandlerContext } from "@netlify/functions";
import { probe } from "@network-utils/tcp-ping";
import { ping, type IPingResult } from "@network-utils/tcp-ping";

const PORT = 80
const TIMEOUT = 3000
const TIMEOUT = 10000
const ATTEMPTS = 3

const handler: Handler = async (event: HandlerEvent, context: HandlerContext) => {
const url = event.queryStringParameters?.url
Expand All @@ -13,11 +14,15 @@ const handler: Handler = async (event: HandlerEvent, context: HandlerContext) =>
}
}

const online = await probe(PORT, url, TIMEOUT);
const pingResult: IPingResult = await ping({address: url, port: PORT, timeout: TIMEOUT, attempts: ATTEMPTS});
const data = {
status: pingResult.errors.length === 0,
latency: pingResult.averageLatency,
}

return {
statusCode: 200,
body: JSON.stringify({ status: online }),
body: JSON.stringify(data),
};
};

Expand Down
Loading

0 comments on commit b27cff4

Please sign in to comment.