Skip to content

Commit

Permalink
doc and move cors ahead of rate-limit to convey error
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlb committed Jul 29, 2022
1 parent 0a53108 commit 768610a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
# Updates to V2
## Installation

### Node dependencies

Running `npm i` will download and nominally install all the dependencies.
[sqlite3](https://www.npmjs.com/package/sqlite3) installation can be tricky.
Running the unit tests with `npm t` will trigger a failure with sqlite3 if there is a problem.

You can build sqlite3 from source with

```
npm --build-from-source install sqlite3
```

### .env file
Create and edit an `.env` file to load server environment variables.
The `sample.env` file serves as a template.

### Certificates
Copy your CA, certificate, and key pem files the location specified in `.env`.

### Start the server

```
npm run build
DEBUG='rsvp:*' nohup npm run start &
```

## Updates to V2
- Move to Typescript.
- Intercept (clean up) authentication with `Express.Application.use()`.
- Use Cognito authentication.
Expand Down
4 changes: 2 additions & 2 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ AWS_USER_POOL_ID=
PORT=8989

# SSL/TLS settings
CA_FILE=config/chain.key.pem
CERTICATE_FILE=config/server.crt.pem
CA_FILE=config/chain.pem
CERTIFICATE_FILE=config/server.crt.pem
KEY_FILE=config/server.key.pem
# HTTPS_PORT=8990

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dotenv.config();

const app = express();

useCors(app); // set up Cors ahead of rate limiter to forward error
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 1000,
Expand All @@ -44,7 +45,6 @@ const server = new Server({
timekeeper
});

useCors(app);
server.setupAlive();

useCognito(app);
Expand Down

0 comments on commit 768610a

Please sign in to comment.