Skip to content

Commit

Permalink
Fix url variable name (#151)
Browse files Browse the repository at this point in the history
* Switch serverless to prod

* Fix URL variable name

Serverless doesn't like when two URLS that are identical doesn't share
the same variables names.
Here, `tagName` was conflicting `tagOrHashName`.
  • Loading branch information
Kmaschta authored May 15, 2019
1 parent 0cf399c commit 1c364e5
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 155 deletions.
4 changes: 2 additions & 2 deletions api/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ run:
$(SERVERLESS) offline start --host=0.0.0.0 --port=3000

deploy:
NODE_ENV=production $(SERVERLESS) deploy --stage beta
NODE_ENV=production $(SERVERLESS) deploy --stage prod

undeploy:
NODE_ENV=production $(SERVERLESS) remove --stage beta
NODE_ENV=production $(SERVERLESS) remove --stage prod

test:
NODE_ENV=test ./node_modules/.bin/jest
Expand Down
301 changes: 150 additions & 151 deletions api/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,160 +1,159 @@
service: comfy

provider:
name: aws
runtime: nodejs8.10
stage: dev
region: eu-west-1
name: aws
runtime: nodejs8.10
stage: prod
region: eu-west-1

functions:

## PROJECTS

projectCreate:
handler: src/handlers/projects.create
description: Create a new project
events:
- http:
method: POST
path: projects
cors: true

projectUpdate:
handler: src/handlers/projects.update
description: Rename a project
events:
- http:
method: PUT
path: projects/{id}
cors: true

projectRemove:
handler: src/handlers/projects.remove
description: Delete a project
events:
- http:
method: DELETE
path: projects/{id}
cors: true

## ENVIRONMENTS

environmentGet:
handler: src/handlers/environments.get
description: List environments of a project
events:
- http:
method: GET
path: projects/{id}/environments
cors: true

environmentCreate:
handler: src/handlers/environments.create
description: Add a new environment to a project
events:
- http:
method: POST
path: projects/{id}/environments
cors: true

environmentUpdate:
handler: src/handlers/environments.update
description: Rename environment of a project
events:
- http:
method: PUT
path: projects/{id}/environments/{environmentName}
cors: true

environmentRemove:
handler: src/handlers/environments.remove
description: Delete environment of a project
events:
- http:
method: DELETE
path: projects/{id}/environments/{environmentName}
cors: true

## CONFIGURATIONS

configurationHistory:
handler: src/handlers/configurations.history
description: List history of a configuration
events:
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/{configName}/history
cors: true
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/history
cors: true

configurationGet:
handler: src/handlers/configurations.get
description: Get tag or hash version of a configuration
events:
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/{configName}
cors: true
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/{configName}/{tagOrHashName}
cors: true

configurationAdd:
handler: src/handlers/configurations.create
description: Add a new version of a configuration
events:
- http:
method: POST
path: projects/{id}/environments/{environmentName}/configurations/{configName}/{tagName}
cors: true

configurationRemove:
handler: src/handlers/configurations.remove
description: Remove a configuration
events:
- http:
method: POST
path: projects/{id}/environments/{environmentName}/configurations/{configName}
cors: true

## TAGS

tagAdd:
handler: src/handlers/tags.create
description: Add a new tag on a configuration
events:
- http:
method: POST
path: projects/{id}/environments/{environmentName}/configurations/{configName}/tags
cors: true

tagUpdate:
handler: src/handlers/tags.update
description: Move a tag
events:
- http:
method: PUT
path: projects/{id}/environments/{environmentName}/configurations/{configName}/tags/{tagName}
cors: true

tagRemove:
handler: src/handlers/tags.remove
description: Remove a tag
events:
- http:
method: DELETE
path: projects/{id}/environments/{environmentName}/configurations/{configName}/tags/{tagName}
cors: true
## PROJECTS

projectCreate:
handler: src/handlers/projects.create
description: Create a new project
events:
- http:
method: POST
path: projects
cors: true

projectUpdate:
handler: src/handlers/projects.update
description: Rename a project
events:
- http:
method: PUT
path: projects/{id}
cors: true

projectRemove:
handler: src/handlers/projects.remove
description: Delete a project
events:
- http:
method: DELETE
path: projects/{id}
cors: true

## ENVIRONMENTS

environmentGet:
handler: src/handlers/environments.get
description: List environments of a project
events:
- http:
method: GET
path: projects/{id}/environments
cors: true

environmentCreate:
handler: src/handlers/environments.create
description: Add a new environment to a project
events:
- http:
method: POST
path: projects/{id}/environments
cors: true

environmentUpdate:
handler: src/handlers/environments.update
description: Rename environment of a project
events:
- http:
method: PUT
path: projects/{id}/environments/{environmentName}
cors: true

environmentRemove:
handler: src/handlers/environments.remove
description: Delete environment of a project
events:
- http:
method: DELETE
path: projects/{id}/environments/{environmentName}
cors: true

## CONFIGURATIONS

configurationHistory:
handler: src/handlers/configurations.history
description: List history of a configuration
events:
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/{configName}/history
cors: true
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/history
cors: true

configurationGet:
handler: src/handlers/configurations.get
description: Get tag or hash version of a configuration
events:
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/{configName}
cors: true
- http:
method: GET
path: projects/{id}/environments/{environmentName}/configurations/{configName}/{tagName}
cors: true

configurationAdd:
handler: src/handlers/configurations.create
description: Add a new version of a configuration
events:
- http:
method: POST
path: projects/{id}/environments/{environmentName}/configurations/{configName}/{tagName}
cors: true

configurationRemove:
handler: src/handlers/configurations.remove
description: Remove a configuration
events:
- http:
method: POST
path: projects/{id}/environments/{environmentName}/configurations/{configName}
cors: true

## TAGS

tagAdd:
handler: src/handlers/tags.create
description: Add a new tag on a configuration
events:
- http:
method: POST
path: projects/{id}/environments/{environmentName}/configurations/{configName}/tags
cors: true

tagUpdate:
handler: src/handlers/tags.update
description: Move a tag
events:
- http:
method: PUT
path: projects/{id}/environments/{environmentName}/configurations/{configName}/tags/{tagName}
cors: true

tagRemove:
handler: src/handlers/tags.remove
description: Remove a tag
events:
- http:
method: DELETE
path: projects/{id}/environments/{environmentName}/configurations/{configName}/tags/{tagName}
cors: true

plugins:
- serverless-webpack
- serverless-offline
- serverless-webpack
- serverless-offline

custom:
webpack:
webpackConfig: './webpack.config.babel.js'
includeModules: true
webpack:
webpackConfig: './webpack.config.babel.js'
includeModules: true
2 changes: 1 addition & 1 deletion api/src/handlers/configurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const get = λ(async event => {
id: projectId,
environmentName,
configName: selector,
tagOrHashName
tagName: tagOrHashName
} = event.pathParameters;
await checkAuthorizationOr403(parseAuthorizationToken(event), projectId, 'read');

Expand Down
2 changes: 1 addition & 1 deletion api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ app.get(
handlerToMiddleware(getConfiguration)
);
app.get(
'/projects/:id/environments/:environmentName/configurations/:configName/:tagOrHashName',
'/projects/:id/environments/:environmentName/configurations/:configName/:tagName',
handlerToMiddleware(getConfiguration)
);
app.post(
Expand Down

0 comments on commit 1c364e5

Please sign in to comment.