@stamhoofd/backend 2.78.2 → 2.78.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.ci.json +32 -16
- package/index.ts +7 -0
- package/jest.config.cjs +17 -0
- package/package.json +10 -10
- package/src/endpoints/auth/GetUserEndpoint.test.ts +0 -10
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.test.ts +726 -0
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +31 -18
- package/src/endpoints/global/members/shouldCheckIfMemberIsDuplicate.ts +9 -21
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +1 -1
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.test.ts +0 -4
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +0 -4
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.test.ts +288 -8
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +8 -13
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +7 -7
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +2 -217
- package/src/endpoints/organization/dashboard/payments/PatchBalanceItemsEndpoint.ts +2 -2
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +6 -3
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.test.ts +4 -6
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +2 -20
- package/src/helpers/AdminPermissionChecker.ts +88 -140
- package/src/helpers/GlobalHelper.ts +6 -1
- package/src/services/FileSignService.ts +3 -3
- package/src/services/MemberRecordStore.ts +155 -0
- package/src/services/PlatformMembershipService.ts +17 -8
- package/tests/e2e/register.test.ts +49 -21
- package/tests/helpers/StripeMocker.ts +7 -2
- package/tests/jest.global.setup.ts +6 -1
- package/tests/jest.setup.ts +10 -2
package/.env.ci.json
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"environment": "test",
|
|
3
3
|
"domains": {
|
|
4
|
-
"dashboard": "dashboard.stamhoofd
|
|
5
|
-
"
|
|
6
|
-
"": "stamhoofd
|
|
7
|
-
"BE": "
|
|
8
|
-
"NL": "
|
|
4
|
+
"dashboard": "dashboard.stamhoofd",
|
|
5
|
+
"marketing": {
|
|
6
|
+
"": "www.be.stamhoofd",
|
|
7
|
+
"BE": "www.be.stamhoofd",
|
|
8
|
+
"NL": "www.nl.stamhoofd"
|
|
9
9
|
},
|
|
10
|
-
"webshop":
|
|
11
|
-
|
|
10
|
+
"webshop": {
|
|
11
|
+
"": "shop.be.stamhoofd",
|
|
12
|
+
"BE": "shop.be.stamhoofd",
|
|
13
|
+
"NL": "shop.nl.stamhoofd"
|
|
14
|
+
},
|
|
15
|
+
"api": "api.stamhoofd",
|
|
16
|
+
"rendererApi": "renderer.stamhoofd",
|
|
17
|
+
|
|
18
|
+
"defaultTransactionalEmail": {
|
|
19
|
+
"": "stamhoofd.be"
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
"defaultBroadcastEmail": {
|
|
23
|
+
"": "stamhoofd.email"
|
|
24
|
+
},
|
|
25
|
+
"webshopCname": "shop.stamhoofd"
|
|
12
26
|
},
|
|
13
27
|
|
|
14
28
|
"PORT": 9091,
|
|
15
29
|
"DB_HOST": "127.0.0.1",
|
|
16
30
|
"DB_USER": "root",
|
|
17
31
|
"DB_PASS": "root",
|
|
18
|
-
"DB_DATABASE": "stamhoofd",
|
|
32
|
+
"DB_DATABASE": "stamhoofd-tests",
|
|
19
33
|
|
|
20
|
-
"SMTP_HOST": "
|
|
34
|
+
"SMTP_HOST": "0.0.0.0",
|
|
21
35
|
"SMTP_USERNAME": "test",
|
|
22
36
|
"SMTP_PASSWORD": "test",
|
|
23
37
|
"SMTP_PORT": 587,
|
|
@@ -26,17 +40,19 @@
|
|
|
26
40
|
"AWS_SECRET_ACCESS_KEY": "",
|
|
27
41
|
"AWS_REGION": "",
|
|
28
42
|
|
|
29
|
-
"SPACES_ENDPOINT": "
|
|
30
|
-
"SPACES_BUCKET": "
|
|
31
|
-
"SPACES_KEY": "",
|
|
32
|
-
"SPACES_SECRET": "",
|
|
43
|
+
"SPACES_ENDPOINT": "anydomain.example",
|
|
44
|
+
"SPACES_BUCKET": "example",
|
|
45
|
+
"SPACES_KEY": "test",
|
|
46
|
+
"SPACES_SECRET": "test",
|
|
33
47
|
|
|
34
48
|
"INTERNAL_SECRET_KEY": "test",
|
|
35
49
|
|
|
36
|
-
"STRIPE_SECRET_KEY": "
|
|
37
|
-
"STRIPE_ENDPOINT_SECRET": "
|
|
50
|
+
"STRIPE_SECRET_KEY": "sk_test_test",
|
|
51
|
+
"STRIPE_ENDPOINT_SECRET": "sk_test",
|
|
38
52
|
"translationNamespace": "digit",
|
|
39
53
|
"platformName": "ravot",
|
|
40
54
|
"userMode": "organization",
|
|
41
|
-
"WHITELISTED_EMAIL_DESTINATIONS": []
|
|
55
|
+
"WHITELISTED_EMAIL_DESTINATIONS": [],
|
|
56
|
+
"MEMBER_NUMBER_ALGORITHM": "Incremental",
|
|
57
|
+
"MEMBER_NUMBER_ALGORITHM_LENGTH": 10
|
|
42
58
|
}
|
package/index.ts
CHANGED
|
@@ -60,10 +60,13 @@ const start = async () => {
|
|
|
60
60
|
await UniqueUserService.check();
|
|
61
61
|
|
|
62
62
|
// Init platform shared struct: otherwise permissions won't work with missing responsibilities
|
|
63
|
+
console.log('Loading platform...');
|
|
63
64
|
await Platform.getSharedStruct();
|
|
64
65
|
|
|
65
66
|
const router = new Router();
|
|
66
67
|
|
|
68
|
+
console.log('Loading endpoints...');
|
|
69
|
+
|
|
67
70
|
// Note: we should load endpoints one by once to have a reliable order of url matching
|
|
68
71
|
await router.loadAllEndpoints(__dirname + '/src/endpoints/global/*');
|
|
69
72
|
await router.loadAllEndpoints(__dirname + '/src/endpoints/admin/*');
|
|
@@ -76,6 +79,7 @@ const start = async () => {
|
|
|
76
79
|
|
|
77
80
|
router.endpoints.push(new CORSPreflightEndpoint());
|
|
78
81
|
|
|
82
|
+
console.log('Creating router...');
|
|
79
83
|
const routerServer = new RouterServer(router);
|
|
80
84
|
routerServer.verbose = false;
|
|
81
85
|
|
|
@@ -104,6 +108,8 @@ const start = async () => {
|
|
|
104
108
|
// Add CORS headers
|
|
105
109
|
routerServer.addResponseMiddleware(CORSMiddleware);
|
|
106
110
|
|
|
111
|
+
console.log('Loading loaders...');
|
|
112
|
+
|
|
107
113
|
// Register Excel loaders
|
|
108
114
|
await import('./src/excel-loaders/members');
|
|
109
115
|
await import('./src/excel-loaders/payments');
|
|
@@ -115,6 +121,7 @@ const start = async () => {
|
|
|
115
121
|
await import('./src/email-recipient-loaders/orders');
|
|
116
122
|
await import('./src/email-recipient-loaders/receivable-balances');
|
|
117
123
|
|
|
124
|
+
console.log('Opening port...');
|
|
118
125
|
routerServer.listen(STAMHOOFD.PORT ?? 9090);
|
|
119
126
|
|
|
120
127
|
const hrend = process.hrtime(bootTime);
|
package/jest.config.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const useGithubActions = !!process.env.GITHUB_ACTIONS;
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
roots: ['<rootDir>/dist'],
|
|
3
5
|
testEnvironment: 'node',
|
|
@@ -5,6 +7,21 @@ module.exports = {
|
|
|
5
7
|
'jest-extended/all',
|
|
6
8
|
'./dist/tests/jest.setup.js',
|
|
7
9
|
],
|
|
10
|
+
reporters: [['jest-console-group-reporter', {
|
|
11
|
+
consoleLevels: ['error', 'warn', 'log'],
|
|
12
|
+
filters: [],
|
|
13
|
+
groups: [],
|
|
14
|
+
onlyFailingTestSuites: true,
|
|
15
|
+
afterEachTest: {
|
|
16
|
+
enable: false,
|
|
17
|
+
},
|
|
18
|
+
afterAllTests: {
|
|
19
|
+
reportType: 'detailed',
|
|
20
|
+
enable: true,
|
|
21
|
+
filePaths: true,
|
|
22
|
+
},
|
|
23
|
+
useGitHubActions: useGithubActions,
|
|
24
|
+
}]],
|
|
8
25
|
globalSetup: './dist/tests/jest.global.setup.js',
|
|
9
26
|
// verbose: true,
|
|
10
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.78.
|
|
3
|
+
"version": "2.78.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"@simonbackx/simple-encoding": "2.20.0",
|
|
38
38
|
"@simonbackx/simple-endpoints": "1.19.1",
|
|
39
39
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
40
|
-
"@stamhoofd/backend-i18n": "2.78.
|
|
41
|
-
"@stamhoofd/backend-middleware": "2.78.
|
|
42
|
-
"@stamhoofd/email": "2.78.
|
|
43
|
-
"@stamhoofd/models": "2.78.
|
|
44
|
-
"@stamhoofd/queues": "2.78.
|
|
45
|
-
"@stamhoofd/sql": "2.78.
|
|
46
|
-
"@stamhoofd/structures": "2.78.
|
|
47
|
-
"@stamhoofd/utility": "2.78.
|
|
40
|
+
"@stamhoofd/backend-i18n": "2.78.4",
|
|
41
|
+
"@stamhoofd/backend-middleware": "2.78.4",
|
|
42
|
+
"@stamhoofd/email": "2.78.4",
|
|
43
|
+
"@stamhoofd/models": "2.78.4",
|
|
44
|
+
"@stamhoofd/queues": "2.78.4",
|
|
45
|
+
"@stamhoofd/sql": "2.78.4",
|
|
46
|
+
"@stamhoofd/structures": "2.78.4",
|
|
47
|
+
"@stamhoofd/utility": "2.78.4",
|
|
48
48
|
"archiver": "^7.0.1",
|
|
49
49
|
"aws-sdk": "^2.885.0",
|
|
50
50
|
"axios": "1.6.8",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "e8c207be8fd75320024f670d5c663eaa8306ba29"
|
|
68
68
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Request } from '@simonbackx/simple-endpoints';
|
|
2
2
|
import { OrganizationFactory, Token, UserFactory } from '@stamhoofd/models';
|
|
3
|
-
import { NewUser } from '@stamhoofd/structures';
|
|
4
3
|
|
|
5
4
|
import { testServer } from '../../../tests/helpers/TestServer';
|
|
6
5
|
import { GetUserEndpoint } from './GetUserEndpoint';
|
|
@@ -19,21 +18,12 @@ describe('Endpoint.GetUser', () => {
|
|
|
19
18
|
|
|
20
19
|
const response = await testServer.test(endpoint, r);
|
|
21
20
|
expect(response.body).toBeDefined();
|
|
22
|
-
|
|
23
|
-
if (!(response.body instanceof NewUser)) {
|
|
24
|
-
throw new Error('Expected NewUser');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
21
|
expect(response.body.id).toEqual(user.id);
|
|
28
22
|
});
|
|
29
23
|
|
|
30
24
|
test('Request user details when not signed in is not working', async () => {
|
|
31
25
|
const organization = await new OrganizationFactory({}).create();
|
|
32
|
-
const user = await new UserFactory({ organization }).create();
|
|
33
|
-
const token = await Token.createToken(user);
|
|
34
|
-
|
|
35
26
|
const r = Request.buildJson('GET', '/v1/user', organization.getApiHost());
|
|
36
|
-
|
|
37
27
|
await expect(testServer.test(endpoint, r)).rejects.toThrow(/missing/i);
|
|
38
28
|
});
|
|
39
29
|
|