diff --git a/config/default.js b/config/default.js index 7462e9b..3ab7a2b 100644 --- a/config/default.js +++ b/config/default.js @@ -27,4 +27,5 @@ module.exports = { KAFKA_CLIENT_CERT: process.env.KAFKA_CLIENT_CERT ? process.env.KAFKA_CLIENT_CERT.replace('\\n', '\n') : null, KAFKA_CLIENT_CERT_KEY: process.env.KAFKA_CLIENT_CERT_KEY ? process.env.KAFKA_CLIENT_CERT_KEY.replace('\\n', '\n') : null, + API_CONTEXT_PATH: process.env.API_CONTEXT_PATH || '/v5/notifications', }; diff --git a/deploy.sh b/deploy.sh index 6cef86e..7a2dad5 100755 --- a/deploy.sh +++ b/deploy.sh @@ -58,6 +58,8 @@ DATABASE_URL=postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_DATABASE; family=$(eval "echo \$${ENV}_AWS_ECS_TASK_FAMILY") AWS_ECS_CONTAINER_NAME=$(eval "echo \$${ENV}_AWS_ECS_CONTAINER_NAME") +API_CONTEXT_PATH=$(eval "echo \$${ENV}_API_CONTEXT_PATH") + echo $APP_NAME configure_aws_cli() { @@ -172,6 +174,10 @@ make_task_def(){ { "name": "PORT", "value": "%s" + }, + { + "name": "API_CONTEXT_PATH", + "value": "%s" } ], "portMappings": [ @@ -192,7 +198,7 @@ make_task_def(){ } ]' - task_def=$(printf "$task_template" $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID "$KAFKA_TOPIC_IGNORE_PREFIX" $KAFKA_URL $DATABASE_URL $AUTHSECRET "$AUTHDOMAIN" "$JWKSURI" $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_ADMIN_TOKEN $LOG_LEVEL $VALID_ISSUERS $PORT $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV) + task_def=$(printf "$task_template" $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID "$KAFKA_TOPIC_IGNORE_PREFIX" $KAFKA_URL $DATABASE_URL $AUTHSECRET "$AUTHDOMAIN" "$JWKSURI" $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_ADMIN_TOKEN $LOG_LEVEL $VALID_ISSUERS $PORT "$API_CONTEXT_PATH" $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV) } register_definition() { diff --git a/src/app.js b/src/app.js index 798f456..3dd02d9 100644 --- a/src/app.js +++ b/src/app.js @@ -112,7 +112,7 @@ function start(handlers) { }); }); - app.use('/', apiRouter); + app.use(config.API_CONTEXT_PATH, apiRouter); app.use((req, res) => { diff --git a/src/routes.js b/src/routes.js index c8be007..15d287d 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1,31 +1,31 @@ 'use strict'; module.exports = { - '/notifications': { + '/list': { get: { controller: 'NotificationController', method: 'listNotifications', }, }, - '/notifications/:id/read': { + '/:id/read': { put: { controller: 'NotificationController', method: 'markAsRead', }, }, - '/notifications/read': { + '/read': { put: { controller: 'NotificationController', method: 'markAllRead', }, }, - '/notifications/:id/seen': { + '/:id/seen': { put: { controller: 'NotificationController', method: 'markAsSeen', }, }, - '/notificationsettings': { + '/settings': { get: { controller: 'NotificationController', method: 'getSettings',