Skip to content

meetnearme/api

Repository files navigation

Meet Near Me API

Getting Started

Running the local SAM dynamodb docker container

  1. $ docker compose build
  2. $ docker compose up

Running the Lambda project

  1. npm i
  2. Create an AWS account if you don't have one.
  3. Create an IAM User
  4. Export aws_access_key_id and aws_secret_access_key env variables.
  5. Run brew install awscli in the terminal to install AWS CLI
  6. Run aws configure to Authorize SST via AWS CLI through Lambda to your local
  7. Create a .env file in the root directory with the necessary environment variables found in .env.example. Here's an example:
  8. Run npm run dev-remote-db to run the Go Lambda Gateway V2 server locally, proxied through Lambda to your local, and using SST deployed AWS resources for DB, etc.

Generate Go templates from *.templ files

  1. Add to your .zshrc / .bashrc
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
  1. go install github.com/a-h/templ/cmd/templ@latest
  2. Run templ generate

Validate home page is working + data-connected

npm run dev should finish with an AWS endpoint, hitting that endpoint should show a list of events in that particular stage's dynamoDb table

Add your AWS local deployment URL to Zitadel config

For auth to work, you must add your AWS local deployment's URL to Zitadel's callback URLs our app-specific redirect settings

  1. Add your AWS deployment URL to Redirect URIs and suffix it like https://{instance-id}.execute-api.us-east-1.amazonaws.com/auth/callback
  2. Add your AWS deployment URL to Post- Logout URIs, your deployment URL looks like this https://{instance-id}.execute-api.us-east-1.amazonaws.com

Validating Event Basic end Points

API Example Curl Requests

  • Add a new event - curl <AWS URL from npm run dev>/api/event - list table Events curl -X POST -H 'Content-Type: application/json' --data-raw $'{"events":[{"eventOwners":["123"],"name":"Espanola Lowriders Good Friday Rally & Bar Crawl","description":"Join us in the low rider capital of the world while we hit up all TWO of our local bars\u0021 You haven\'t seen a real lowrider if you haven\'t visited Espanola\u0021","startTime":"2025-02-15T18:30:00Z","address":"Espanola, NM","lat": 36.015303,"long":-106.066063}]}' <AWS URL from npm run dev>/api/event

Reference for interacting with dynamodb from aws cli v2

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/index.html

Project Maintenance

Rebuilding the templ binary

If you see an error like (!) templ version check failed: generator v0.2.513 is older than templ version v0.2.648 found in go.mod file, consider upgrading templ CLI, you need to update the templ go binary

  1. go install github.com/a-h/templ/cmd/templ@latest

Updating env vars

For an overview of our current env vars with an explanation of each, look at .env.example

When updating env vars, the changes need to be made in 4 places:

  1. stacks/ApiStack.ts
  2. .github/actions/set_aws_creds_env_vars/action.yml (inputs section)
  3. .github/actions/set_aws_creds_env_vars/action.yml (run section where vars are echod)
  4. .env.example to clarify in version control what our currently-used env vars are

Setting up AWS DNS in Route53 with Custom Domain names for API Gateway

For *.meetnear.me and *.devnear.me there is some custom configuration required at the API Gateway level, DNS nameserver level, and Route53 configuration level

  1. DNS Level - at the time of writing, the *.me TLD can't be registered through Amazon, so it's handled through Namecheap.com.
    1. First, go to Route53 in AWS console and add a new "Hosted Zone" (we'll use devnear.me as an example)
    2. In the list view, look for Type: NS and copy the Values to Namecheap.com under the admin tab for devnear.me
  2. API Gateway / Route53 Level - To map the DNS to Route53 (covered in the next step), you must first configure at the API Gateway level
    1. First, go to API Gateway > Custom Domain Names and click Create.
    2. Enter the new domain, in our case devnear.me
    3. Under ACM Certificate if this is a new domain, you might need to click Create a new ACM Certificate
    4. After initiating the certificate creation, you'll be taken to the AWS cert admin panel where you need to click Create Records in Route53 to verify domain ownership for the cert
    5. Go to the API Gateway > Custom Domains in the AWS console
    6. Click Create
    7. Choose the newly created (and now verified via the Route53 records added above) cert
    8. Go to devnear.me (your newly created Custom Domain Name) > Configure API Mappings
    9. Set API value to the Cloudformation resource you want to map to devnear.me
    10. Go back to Route53 console to confirm the mapped A records are set correctly. If they are, the Value for the A record will be (slightly confusingly) d-<alpha-numeric>.execute-api.us-east-1.amazonaws.com. This should be different from the ApiEndpoint seen in Github Actions output for the deployment, which typically looks like ApiEndpoint: https://<alpha-numeric>.execute-api.us-east-1.amazonaws.com. The alpha-numeric characters will not match, and the correct A record should be prefixed with d-

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •