From 8a83417b7d1d606867f2a026bf0dc9dc2900ed5a Mon Sep 17 00:00:00 2001 From: Collin Duncan <3679940+cgduncan7@users.noreply.github.com> Date: Mon, 15 Nov 2021 12:32:49 +0100 Subject: [PATCH] Updating README and local execution --- README.md | 25 ++++++++++++++++++++++++- package.json | 1 + src/local.ts | 8 ++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9fc0ea6..042a28f 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -# autobaan \ No newline at end of file +# autobaan + +Automatic court reservation! + +## Setup + +### Requirements + +- Node.js (14.x) +- npm (8.x) +- nvm (optional) + +#### Using nvm + +1. Install [nvm](https://github.com/nvm-sh/nvm#installing-and-updating) +1. `nvm use` will use version specified in `.nvmrc` +1. `nvm install-latest-npm` will upgrade NPM to latest version (8.x) + +### Usage + +```bash +npm install +npm run local +``` \ No newline at end of file diff --git a/package.json b/package.json index c97f06b..894a14f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "scripts": { "build": "tsc", + "local": "npx ts-node src/local.ts", "zip": "mkdir deploy && zip deploy/reservation-lambda.zip -r dist" }, "author": "", diff --git a/src/local.ts b/src/local.ts index 7bbe505..f547bee 100644 --- a/src/local.ts +++ b/src/local.ts @@ -14,17 +14,17 @@ const run = async (request: IncomingRequest) => { // get supplied args const args = process.argv.filter((_, index) => index >= 2) if (args.length !== 7) { - console.error('Usage: ./local ') + console.error('Usage: npm run local ') process.exit(1) } -const [year, month, day, startTime, endTime, opponentName, opponentId] = args +const [username, password, year, month, day, startTime, endTime, opponentName, opponentId] = args const [startHour, startMinute] = startTime.split(':').map((t) => Number.parseInt(t)) const [endHour, endMinute] = endTime.split(':').map((t) => Number.parseInt(t)) run({ - username: process.env.USERNAME ?? '', - password: process.env.PASSWORD ?? '', + username: username, + password: password, dateTimes: [{ year: Number.parseInt(year), month: Number.parseInt(month),