Просмотр исходного кода

:recycle: stub some test stuff

undefined
j 2 лет назад
Родитель
Сommit
dfef2dc72f

+ 9
- 0
backend/lib/plugins/profile.js Просмотреть файл

1
 const Objection = require('objection')
1
 const Objection = require('objection')
2
 const Schmervice = require('@hapipal/schmervice')
2
 const Schmervice = require('@hapipal/schmervice')
3
 
3
 
4
+const Jwt = require('hapi-auth-jwt2')
5
+const JwtStrategy = require('../auth/strategies/jwt')
6
+
4
 const ProfileModel = require('../models/profile')
7
 const ProfileModel = require('../models/profile')
5
 const TagModel = require('../models/tag')
8
 const TagModel = require('../models/tag')
6
 const TagAssociationModel = require('../models/tag-association')
9
 const TagAssociationModel = require('../models/tag-association')
29
     name: 'profile-plugin',
32
     name: 'profile-plugin',
30
     version: '1.0.0',
33
     version: '1.0.0',
31
     register: async (server, options) => {
34
     register: async (server, options) => {
35
+        await server.register(Jwt)
32
         await server.registerModel(ProfileModel)
36
         await server.registerModel(ProfileModel)
33
         await server.registerModel(TagModel)
37
         await server.registerModel(TagModel)
34
         await server.registerModel(TagAssociationModel)
38
         await server.registerModel(TagAssociationModel)
38
         await server.registerModel(ZipCodeModel)
42
         await server.registerModel(ZipCodeModel)
39
         await server.registerModel(MatchQueueModel)
43
         await server.registerModel(MatchQueueModel)
40
 
44
 
45
+        const mainApp = server.registrations['main-app-plugin']
46
+        const jwtOptions = JwtStrategy(mainApp.options)
47
+        server.auth.strategy('default_jwt', 'jwt', jwtOptions)
48
+        server.auth.default('default_jwt')
49
+
41
         // Bind to global context
50
         // Bind to global context
42
         // So we can use Objection transactions
51
         // So we can use Objection transactions
43
         server.bind({
52
         server.bind({

+ 7
- 3
backend/package-lock.json Просмотреть файл

1926
             }
1926
             }
1927
         },
1927
         },
1928
         "node_modules/caniuse-lite": {
1928
         "node_modules/caniuse-lite": {
1929
-            "version": "1.0.30001423",
1930
-            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001423.tgz",
1931
-            "integrity": "sha512-09iwWGOlifvE1XuHokFMP7eR38a0JnajoyL3/i87c8ZjRWRrdKo1fqjNfugfBD0UDBIOz0U+jtNhJ0EPm1VleQ==",
1929
+            "version": "1.0.30001565",
1930
+            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001565.tgz",
1931
+            "integrity": "sha512-xrE//a3O7TP0vaJ8ikzkD2c2NgcVUvsEe2IvFTntV4Yd1Z9FVzh+gW+enX96L0psrbaFMcVcH2l90xNuGDWc8w==",
1932
             "dev": true,
1932
             "dev": true,
1933
             "funding": [
1933
             "funding": [
1934
                 {
1934
                 {
1938
                 {
1938
                 {
1939
                     "type": "tidelift",
1939
                     "type": "tidelift",
1940
                     "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
1940
                     "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
1941
+                },
1942
+                {
1943
+                    "type": "github",
1944
+                    "url": "https://github.com/sponsors/ai"
1941
                 }
1945
                 }
1942
             ]
1946
             ]
1943
         },
1947
         },

+ 5
- 0
backend/tests/matchqueue.spec.js Просмотреть файл

60
      */
60
      */
61
     server.registerModel = () => {}
61
     server.registerModel = () => {}
62
     server.models = () => ({ Aspect, AspectLabel, MatchQueue, Profile })
62
     server.models = () => ({ Aspect, AspectLabel, MatchQueue, Profile })
63
+    server.registrations = {
64
+        'main-app-plugin': {
65
+            options: {},
66
+        },
67
+    }
63
     /**
68
     /**
64
      * Register Routes and Services as usual
69
      * Register Routes and Services as usual
65
      */
70
      */

+ 5
- 0
backend/tests/profile.spec.js Просмотреть файл

49
      */
49
      */
50
     server.registerModel = () => {}
50
     server.registerModel = () => {}
51
     server.models = () => ({ Profile, Tag })
51
     server.models = () => ({ Profile, Tag })
52
+    server.registrations = {
53
+        'main-app-plugin': {
54
+            options: {},
55
+        },
56
+    }
52
     /**
57
     /**
53
      * Register Routes and Services as usual
58
      * Register Routes and Services as usual
54
      */
59
      */

+ 5
- 0
backend/tests/respond.spec.js Просмотреть файл

52
      */
52
      */
53
     server.registerModel = () => {}
53
     server.registerModel = () => {}
54
     server.models = () => ({ Response, ResponseKey })
54
     server.models = () => ({ Response, ResponseKey })
55
+    server.registrations = {
56
+        'main-app-plugin': {
57
+            options: {},
58
+        },
59
+    }
55
     /**
60
     /**
56
      * Register Routes and Services as usual
61
      * Register Routes and Services as usual
57
      */
62
      */

+ 5
- 0
backend/tests/score.spec.js Просмотреть файл

93
         Profile,
93
         Profile,
94
         ZipCode,
94
         ZipCode,
95
     })
95
     })
96
+    server.registrations = {
97
+        'main-app-plugin': {
98
+            options: {},
99
+        },
100
+    }
96
     /**
101
     /**
97
      * Register Routes and Services as usual
102
      * Register Routes and Services as usual
98
      */
103
      */

+ 5
- 0
backend/tests/update.spec.js Просмотреть файл

66
      */
66
      */
67
     server.registerModel = () => {}
67
     server.registerModel = () => {}
68
     server.models = () => ({ Response, ResponseKey })
68
     server.models = () => ({ Response, ResponseKey })
69
+    server.registrations = {
70
+        'main-app-plugin': {
71
+            options: {},
72
+        },
73
+    }
69
     /**
74
     /**
70
      * Register Routes and Services as usual
75
      * Register Routes and Services as usual
71
      */
76
      */

+ 2
- 2
frontend/src/utils/db.js Просмотреть файл

1
-const domain = import.meta.env.VITE_API_HOST
2
-const port = import.meta.env.VITE_API_PORT
1
+const domain = import.meta.env ? import.meta.env.VITE_API_HOST : 'localhost'
2
+const port = import.meta.env ? import.meta.env.VITE_API_PORT : 3000
3
 const httpProtocol = `http`
3
 const httpProtocol = `http`
4
 const prefix = 'api'
4
 const prefix = 'api'
5
 const remote = `${httpProtocol}://${domain}:${port}/${prefix}`
5
 const remote = `${httpProtocol}://${domain}:${port}/${prefix}`

Загрузка…
Отмена
Сохранить