aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--app/Controllers/Http/ServiceController.js12
-rw-r--r--database/adonis.sqlitebin45056 -> 0 bytes
-rw-r--r--database/migrations/1566385379883_service_schema.js1
-rw-r--r--package.json3
-rw-r--r--start/routes.js2
-rw-r--r--yarn.lock2
7 files changed, 16 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 42d88df..5d34e01 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ tmp
9 9
10# The development sqlite file 10# The development sqlite file
11database/development.sqlite 11database/development.sqlite
12database/adonis.sqlite
diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js
index 47a8a6f..0fcbec0 100644
--- a/app/Controllers/Http/ServiceController.js
+++ b/app/Controllers/Http/ServiceController.js
@@ -2,6 +2,7 @@
2 2
3const User = use('App/Models/User'); 3const User = use('App/Models/User');
4const Service = use('App/Models/Service'); 4const Service = use('App/Models/Service');
5const uuid = require('uuid/v4');
5 6
6class ServiceController { 7class ServiceController {
7 // Create a new service for user 8 // Create a new service for user
@@ -18,8 +19,15 @@ class ServiceController {
18 19
19 const data = request.all(); 20 const data = request.all();
20 21
22 // Get new, unused uuid
23 let serviceId;
24 do {
25 serviceId = uuid();
26 } while((await Service.all()).rows.length > 0)
27
21 const service = await Service.create({ 28 const service = await Service.create({
22 userId: auth.user.id, 29 userId: auth.user.id,
30 serviceId,
23 name: data.name, 31 name: data.name,
24 recipeId: data.recipeId, 32 recipeId: data.recipeId,
25 settings: JSON.stringify(data) 33 settings: JSON.stringify(data)
@@ -28,7 +36,7 @@ class ServiceController {
28 return response.send({ 36 return response.send({
29 "data": { 37 "data": {
30 userId: auth.user.id, 38 userId: auth.user.id,
31 id: service.id, 39 id: serviceId,
32 "isEnabled": true, 40 "isEnabled": true,
33 "isNotificationEnabled": true, 41 "isNotificationEnabled": true,
34 "isBadgeEnabled": true, 42 "isBadgeEnabled": true,
@@ -74,7 +82,7 @@ class ServiceController {
74 "workspaces": [], 82 "workspaces": [],
75 "iconUrl": null, 83 "iconUrl": null,
76 ...JSON.parse(service.settings), 84 ...JSON.parse(service.settings),
77 "id": service.id, 85 "id": service.serviceId,
78 "name": service.name, 86 "name": service.name,
79 "recipeId": service.recipeId, 87 "recipeId": service.recipeId,
80 "userId": auth.user.id, 88 "userId": auth.user.id,
diff --git a/database/adonis.sqlite b/database/adonis.sqlite
deleted file mode 100644
index 9042fc9..0000000
--- a/database/adonis.sqlite
+++ /dev/null
Binary files differ
diff --git a/database/migrations/1566385379883_service_schema.js b/database/migrations/1566385379883_service_schema.js
index bdc066e..a725699 100644
--- a/database/migrations/1566385379883_service_schema.js
+++ b/database/migrations/1566385379883_service_schema.js
@@ -8,6 +8,7 @@ class ServiceSchema extends Schema {
8 this.create('services', (table) => { 8 this.create('services', (table) => {
9 table.increments() 9 table.increments()
10 table.string('userId', 80).notNullable() 10 table.string('userId', 80).notNullable()
11 table.string('serviceId', 80).notNullable()
11 table.string('name', 80).notNullable() 12 table.string('name', 80).notNullable()
12 table.string('recipeId', 254).notNullable() 13 table.string('recipeId', 254).notNullable()
13 table.json('settings') 14 table.json('settings')
diff --git a/package.json b/package.json
index 6dcffd6..2c8179f 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,8 @@
26 "@adonisjs/lucid": "^6.1.3", 26 "@adonisjs/lucid": "^6.1.3",
27 "atob": "^2.1.2", 27 "atob": "^2.1.2",
28 "pg": "^7.12.1", 28 "pg": "^7.12.1",
29 "sqlite3": "^4.1.0" 29 "sqlite3": "^4.1.0",
30 "uuid": "^3.3.3"
30 }, 31 },
31 "devDependencies": {}, 32 "devDependencies": {},
32 "autoload": { 33 "autoload": {
diff --git a/start/routes.js b/start/routes.js
index 3aca58e..ef688c8 100644
--- a/start/routes.js
+++ b/start/routes.js
@@ -42,7 +42,7 @@ Route.group(() => {
42 Route.get('payment/plans', 'StaticController.plans') 42 Route.get('payment/plans', 'StaticController.plans')
43 Route.get('recipes/popular', 'StaticController.popularRecipes') 43 Route.get('recipes/popular', 'StaticController.popularRecipes')
44 Route.get('recipes/update', 'StaticController.emptyArray') 44 Route.get('recipes/update', 'StaticController.emptyArray')
45 Route.get('announcements/:version', 'StaticController.announcement') 45 // Route.get('announcements/:version', 'StaticController.announcement')
46}).prefix('v1') 46}).prefix('v1')
47 47
48Route.get('/', () => { 48Route.get('/', () => {
diff --git a/yarn.lock b/yarn.lock
index 6443b7b..d9558e7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3573,7 +3573,7 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1:
3573 resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" 3573 resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
3574 integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= 3574 integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
3575 3575
3576uuid@^3.3.2: 3576uuid@^3.3.2, uuid@^3.3.3:
3577 version "3.3.3" 3577 version "3.3.3"
3578 resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866" 3578 resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
3579 integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ== 3579 integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==