Updating README and local execution

This commit is contained in:
Collin Duncan 2021-11-15 12:32:49 +01:00
parent ba0afacf91
commit 8a83417b7d
No known key found for this signature in database
3 changed files with 29 additions and 5 deletions

View file

@ -1 +1,24 @@
# autobaan # 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 <username> <password> <year> <month> <day> <startTime> <endTime> <opponentName> <opponentId>
```

View file

@ -8,6 +8,7 @@
}, },
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"local": "npx ts-node src/local.ts",
"zip": "mkdir deploy && zip deploy/reservation-lambda.zip -r dist" "zip": "mkdir deploy && zip deploy/reservation-lambda.zip -r dist"
}, },
"author": "", "author": "",

View file

@ -14,17 +14,17 @@ const run = async (request: IncomingRequest) => {
// get supplied args // get supplied args
const args = process.argv.filter((_, index) => index >= 2) const args = process.argv.filter((_, index) => index >= 2)
if (args.length !== 7) { if (args.length !== 7) {
console.error('Usage: ./local <year> <month> <day> <startTime> <endTime> <opponentName> <opponentId>') console.error('Usage: npm run local <username> <password> <year> <month> <day> <startTime> <endTime> <opponentName> <opponentId>')
process.exit(1) 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 [startHour, startMinute] = startTime.split(':').map((t) => Number.parseInt(t))
const [endHour, endMinute] = endTime.split(':').map((t) => Number.parseInt(t)) const [endHour, endMinute] = endTime.split(':').map((t) => Number.parseInt(t))
run({ run({
username: process.env.USERNAME ?? '', username: username,
password: process.env.PASSWORD ?? '', password: password,
dateTimes: [{ dateTimes: [{
year: Number.parseInt(year), year: Number.parseInt(year),
month: Number.parseInt(month), month: Number.parseInt(month),