From 1c364e56f6943049e6b5fb93193d9a2463a1cd11 Mon Sep 17 00:00:00 2001 From: Kmaschta Date: Wed, 15 May 2019 18:00:21 +0200 Subject: [PATCH] Fix url variable name (#151) * 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`. --- api/makefile | 4 +- api/serverless.yml | 301 ++++++++++++++--------------- api/src/handlers/configurations.js | 2 +- api/src/index.js | 2 +- 4 files changed, 154 insertions(+), 155 deletions(-) diff --git a/api/makefile b/api/makefile index 5f5fe32..569ee29 100644 --- a/api/makefile +++ b/api/makefile @@ -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 diff --git a/api/serverless.yml b/api/serverless.yml index 57b86b9..0c8f744 100644 --- a/api/serverless.yml +++ b/api/serverless.yml @@ -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 diff --git a/api/src/handlers/configurations.js b/api/src/handlers/configurations.js index f23345e..78660bd 100644 --- a/api/src/handlers/configurations.js +++ b/api/src/handlers/configurations.js @@ -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'); diff --git a/api/src/index.js b/api/src/index.js index d47e7d5..8266d01 100644 --- a/api/src/index.js +++ b/api/src/index.js @@ -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(