Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Commit c461358

Browse files
committed
Upload initial files
1 parent f9d501b commit c461358

8 files changed

Lines changed: 287 additions & 1 deletion

File tree

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"

.github/workflows/npm-publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: 16
18+
- run: npm ci
19+
# Once tests are added, this will be revisited.
20+
# - run: npm test
21+
22+
publish-npm:
23+
needs: build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-node@v2
28+
with:
29+
node-version: 16
30+
registry-url: https://registry.npmjs.org/
31+
- run: npm ci
32+
- run: tsc -p tsconfig.json
33+
- run: rm completeScreening.ts
34+
- run: npm publish --access public
35+
env:
36+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.github
2+
tsconfig.json
3+
objectToWrapper.ts
4+
*.test.*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# complete-screening
2-
Completes the New York City Department of Education Health Screening on Guest Mode
2+
Completes the New York City Department of Education Health Screening on Guest Mode.
33

44
The exported function will return a boolean indicating if the request completed successfully.

completeScreening.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* Copyright (C) 2021 PythonCoderAS
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
import axios from "axios";
18+
import objectToWrapper from "@healthscreening/object-to-wrapper"
19+
import { screeningTypeType } from "@healthscreening/screening-types";
20+
21+
export interface SendRequestParams {
22+
firstName: string;
23+
lastName: string;
24+
email: string;
25+
isVaxxed: boolean;
26+
type: screeningTypeType;
27+
}
28+
29+
export interface SubmitParams {
30+
Type: screeningTypeType;
31+
IsOther: boolean;
32+
IsStudent: 0 | 1;
33+
FirstName: string;
34+
LastName: string;
35+
Email: string;
36+
State: string;
37+
Location: string;
38+
Floor: string | null;
39+
Answer1: 0 | 1;
40+
Answer2: 0 | 1;
41+
Answer3?: 0 | 1;
42+
Answer4?: 0 | 1;
43+
}
44+
export default async function completeScreening(
45+
options: SendRequestParams
46+
): Promise<boolean> {
47+
// We assume the browser has been started already.
48+
49+
const obj: SubmitParams = {
50+
Type: options.type || "G",
51+
IsOther: false,
52+
IsStudent: 1,
53+
FirstName: options.firstName,
54+
LastName: options.lastName,
55+
Email: options.email,
56+
State: "NY",
57+
Location: "X445",
58+
Floor: null,
59+
Answer1: 0,
60+
Answer2: 0,
61+
};
62+
if (options.isVaxxed) {
63+
obj.Answer3 = 0;
64+
obj.Answer4 = 0;
65+
} else {
66+
obj.Answer3 = 1;
67+
}
68+
const response = await axios.post(
69+
"https://healthscreening.schools.nyc/home/submit",
70+
new URLSearchParams(objectToWrapper(obj)).toString(),
71+
{
72+
headers: {
73+
accept: "*/*",
74+
"accept-language": "en-US,en;q=0.9,bn;q=0.8",
75+
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
76+
},
77+
}
78+
);
79+
return response.status / 100 < 4;
80+
}

package-lock.json

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@healthscreening/complete-screening",
3+
"version": "1.0.0",
4+
"description": "Completes the New York City Department of Education Health Screening on Guest Mode.",
5+
"main": "completeScreening.js",
6+
"types": "completeScreening.d.ts",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/HealthScreening/complete-screening.git"
10+
},
11+
"engines": {
12+
"node": ">=8.X.X"
13+
},
14+
"author": "PythonCoderAS <sarkaraoyan@gmail.com>",
15+
"license": "GNU General Public License v3.0",
16+
"bugs": {
17+
"url": "https://github.com/HealthScreening/complete-screening/issues"
18+
},
19+
"homepage": "https://github.com/HealthScreening/complete-screening#readme",
20+
"dependencies": {
21+
"@healthscreening/object-to-wrapper": "^1.0.0",
22+
"axios": "^0.24.0",
23+
"@healthscreening/screening-types": "^1.0.0"
24+
},
25+
"devDependencies": {
26+
"typescript": "^4.5.4"
27+
}
28+
}

tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es2019",
5+
"strict": true,
6+
"allowJs": true,
7+
"declaration": true
8+
},
9+
"exclude": [
10+
"node_modules"
11+
]
12+
}

0 commit comments

Comments
 (0)