|
22 | 22 | Provision a Lambda based relay script that will, self test, self deploy and consume SendGrid webhook endpoints and relay them to Mongodb's Atlas cloud service. Also included as part of the microservice is information on how to setup the AWS IAM policies with the least permissive [policy](.iam.md#example-policy) possible. The service is deployable using the Travis github hooks and will automatically test with local integrations of NodeJS and MongoDB that are stored within the docker containers.
|
23 | 23 |
|
24 | 24 |
|
25 |
| -## Local Development via Docker with Mapped volumes |
26 |
| -The folder ./.docker folder contains the dev containers as well as the travis production containers. [**.env.example**](#process) must be populated when running in development as per the process below. |
| 25 | +## Local Dependancies |
| 26 | +1. npm |
| 27 | +2. Docker (optional but recommended) |
27 | 28 |
|
28 |
| -### Local Dependancies |
29 |
| -1. Docker |
30 |
| -2. docker-compose |
31 |
| -3. npm |
32 |
| - |
33 |
| -### Process |
| 29 | +## Process |
34 | 30 | 1. Copy .env.example to .env
|
35 |
| -2. Update ENVIRONMENT to "development" |
36 |
| -3. Change TESTFILE location if desired |
37 |
| -4. Install NPM dependancies |
| 31 | +2. Check DATABASE points to valid MongoDB URI ([mongo setup](#mongo-setup)) |
| 32 | +3. Install NPM dependancies |
38 | 33 | ```bash
|
39 | 34 | npm install
|
40 | 35 | ```
|
41 | 36 |
|
42 |
| -5. Init Docker |
| 37 | +4. Test |
43 | 38 | ```bash
|
44 | 39 | # run test via local docker containers
|
45 |
| -npm run test |
| 40 | +npm test |
46 | 41 | # clean up containers
|
47 | 42 | npm run cleanup
|
48 | 43 | ```
|
49 | 44 |
|
50 |
| -- This will run the lambda function with the 'event' argument data overwritten from the TESTFILE json. |
51 |
| -- docker exits when lambda function returns code (sendgrid_app_1 exited with code ~) |
52 |
| -- ~ = 0 = success; |
| 45 | +## Mongo Setup |
| 46 | +You can set the DATABASE environment variable to any valid Mongo connection URI. |
| 47 | + |
| 48 | +However, it is recommend you test to a local isolated Mongo instance. |
| 49 | + |
| 50 | +Via provided NPM script: |
| 51 | +```bash |
| 52 | +npm run setup-mongo |
| 53 | +``` |
| 54 | + |
| 55 | +Via Docker directly: |
| 56 | +```bash |
| 57 | +docker run --detach --name sendgrid-mongo --expose 27017 -p 127.0.0.1:27017:27017/tcp mongo |
| 58 | +``` |
53 | 59 |
|
| 60 | +To change local port due to any conflicts: |
| 61 | +- Update `127.0.0.1:27017` to `127.0.0.1:xxxxx` where `xxxxx` is new port. |
| 62 | +- Update .env connection string with new port |
| 63 | +- This can be ran manually, or updated in `package.json` for ongoing convenience |
54 | 64 |
|
55 | 65 | ## Pending updates
|
56 | 66 | - [X] enforce unique index on sg_message_id
|
|
0 commit comments