From d65129698defb44e3ddfe6fca0df9d0ea0db6028 Mon Sep 17 00:00:00 2001 From: Mats Andreassen Date: Tue, 16 Jun 2020 15:56:28 +0200 Subject: [PATCH] Added vtfk test and prod deployment profiles --- .gitignore | 3 +- now-prod.json | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++ now-test.json | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 +- 4 files changed, 356 insertions(+), 3 deletions(-) create mode 100644 now-prod.json create mode 100644 now-test.json diff --git a/.gitignore b/.gitignore index 21df3e9..3e3994a 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ jspm_packages .node_repl_history # Env -.env \ No newline at end of file +.env +.vercel \ No newline at end of file diff --git a/now-prod.json b/now-prod.json new file mode 100644 index 0000000..8c0c168 --- /dev/null +++ b/now-prod.json @@ -0,0 +1,175 @@ +{ + "version": 2, + "name": "minelev-logs-stats", + "scope": "vtfk", + "alias": [ + "stats.minelev.vtfk.no" + ], + "env": { + "NODE_ENV": "production", + "MONGODB_CONNECTION": "@minelev-prod-db-connection-read", + "MONGODB_COLLECTION": "@minelev-prod-db-collection-logs", + "MONGODB_COLLECTION_TJOMMI": "@minelev-prod-db-collection-pifu", + "MONGODB_NAME": "@minelev-prod-db-name" + }, + "builds": [ + { + "src": "/README.md", + "use": "@now/md" + }, + { + "src": "/api/*.js", + "use": "@now/node" + } + ], + "routes": [ + { + "src": "/", + "dest": "/README.html" + }, + { + "src": "/favicon.ico", + "dest": "/static/favicon.ico" + }, + { + "src": "/stats/total", + "dest": "/api/total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/total/category/(.*)", + "dest": "/api/category-total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/total/(.*)", + "dest": "/api/total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/email", + "dest": "/api/email.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/queue", + "dest": "/api/queue.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/usage", + "dest": "/api/usage.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/usage/(.*)", + "dest": "/api/usage.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/time", + "dest": "/api/time.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/time/(.*)", + "dest": "/api/time.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/schools", + "dest": "/api/schools.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/schools/category/(.*)", + "dest": "/api/category-schools.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/schools/(.*)", + "dest": "/api/schools.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/classes", + "dest": "/api/groups.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/classes/category/(.*)", + "dest": "/api/category-classes.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/classes/(.*)", + "dest": "/api/groups.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/categories", + "dest": "/api/categories.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/students", + "dest": "/api/students-total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/(.*)", + "dest": "/README.html" + } + ] +} \ No newline at end of file diff --git a/now-test.json b/now-test.json new file mode 100644 index 0000000..bc19d6a --- /dev/null +++ b/now-test.json @@ -0,0 +1,175 @@ +{ + "version": 2, + "name": "minelev-logs-stats-test", + "scope": "vtfk", + "alias": [ + "stats.minelev.vtfk.dev" + ], + "env": { + "NODE_ENV": "production", + "MONGODB_CONNECTION": "@minelev-test-db-connection-read", + "MONGODB_COLLECTION": "@minelev-test-db-collection-logs", + "MONGODB_COLLECTION_TJOMMI": "@minelev-test-db-collection-pifu", + "MONGODB_NAME": "@minelev-test-db-name" + }, + "builds": [ + { + "src": "/README.md", + "use": "@now/md" + }, + { + "src": "/api/*.js", + "use": "@now/node" + } + ], + "routes": [ + { + "src": "/", + "dest": "/README.html" + }, + { + "src": "/favicon.ico", + "dest": "/static/favicon.ico" + }, + { + "src": "/stats/total", + "dest": "/api/total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/total/category/(.*)", + "dest": "/api/category-total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/total/(.*)", + "dest": "/api/total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/email", + "dest": "/api/email.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/queue", + "dest": "/api/queue.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/usage", + "dest": "/api/usage.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/usage/(.*)", + "dest": "/api/usage.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/time", + "dest": "/api/time.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/time/(.*)", + "dest": "/api/time.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/schools", + "dest": "/api/schools.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/schools/category/(.*)", + "dest": "/api/category-schools.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/schools/(.*)", + "dest": "/api/schools.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/classes", + "dest": "/api/groups.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/classes/category/(.*)", + "dest": "/api/category-classes.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/classes/(.*)", + "dest": "/api/groups.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/categories", + "dest": "/api/categories.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/students", + "dest": "/api/students-total.js", + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" + } + }, + { + "src": "/stats/(.*)", + "dest": "/README.html" + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 9cc5308..8b1437b 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,10 @@ "coverage": "nyc ava", "coveralls": "nyc ava && nyc report --reporter=lcov && cat coverage/lcov.info | coveralls", "standard-fix": "standard --fix", - "deploy": "npm test && now --prod", - "deploy-demo": "npm test && now --local-config now-demo.json --prod", + "deploy": "npm test && now --prod && rm -rf .vercel", + "deploy:prod": "npm test && now --local-config now-prod.json --prod --confirm && rm -rf .vercel", + "deploy:test": "npm test && now --local-config now-test.json --prod --confirm && rm -rf .vercel", + "deploy:demo": "npm test && now --local-config now-demo.json --prod --confirm && rm -rf .vercel", "dev": "now dev", "refresh": "rm -rf node_modules && rm package-lock.json && npm install" },