Skip to content

Commit

Permalink
Fix response code (#124)
Browse files Browse the repository at this point in the history
* Fix code

* Update readme to include correct startup command

* Install netlify cypress plugin

* Fix comment

* Update netlify CLI

* Use dynamic URL for serverless functions
  • Loading branch information
sam-myers authored Oct 13, 2023
1 parent 76dae1a commit 7ab53fd
Show file tree
Hide file tree
Showing 6 changed files with 8,985 additions and 703 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Prerequisites:
- Download the `netlify` CLI to build & run the serverless functions locally.
- Download the `doppler` CLI for development secrets.

Start with `doppler run -- cargo run`.
Start with `doppler run -- netlify dev`.
8 changes: 4 additions & 4 deletions functions/packages/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

type Config struct {
// Server
BaseUrl string `env:"BASE_URL"`
Url string `env:"URL"`

// Airtable
// Spotify
SpotifyId string `yaml:"spotify_id" env:"SPOTIFY_ID"`
SpotifySecret string `yaml:"spotify_secret" env:"SPOTIFY_SECRET"`

Expand Down Expand Up @@ -50,8 +50,8 @@ func (c *Config) requiredVarsSet() error {
return fmt.Errorf("SPOTIFY_SECRET is required")
}

if c.BaseUrl == "" {
return fmt.Errorf("BASE_URL is required")
if c.Url == "" {
return fmt.Errorf("URL is required")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion functions/search/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func handler(ctx context.Context, request events.APIGatewayProxyRequest) (*event
Name: show.Name,
Description: show.Description,
ImageUrl: imageUrl,
RssUrl: fmt.Sprintf("%s/.netlify/functions/spotify-rss?id=%s", config.BaseUrl, show.ID),
RssUrl: fmt.Sprintf("%s/.netlify/functions/spotify-rss?id=%s", config.Url, show.ID),
})
}

Expand Down
4 changes: 2 additions & 2 deletions functions/spotify-rss/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func handler(ctx context.Context, request events.APIGatewayProxyRequest) (*event
}

return &events.APIGatewayProxyResponse{
StatusCode: 500,
Headers: map[string]string{"Content-Type": "text/plain"},
StatusCode: 200,
Headers: map[string]string{"Content-Type": "application/xml"},
Body: buff.String(),
}, nil
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"devDependencies": {
"cypress": "11.2.0"
"cypress": "11.2.0",
"netlify-cli": "^16.7.0",
"netlify-plugin-cypress": "^2.2.1"
}
}
Loading

0 comments on commit 7ab53fd

Please sign in to comment.