-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.js
57 lines (45 loc) · 2.2 KB
/
seed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { DatabaseBuilder } from '../../tests/tooling/database-builder/database-builder.js';
import { localizedChallengesBuilder } from './data/localized-challenges.js';
import { localizedChallengesAttachmentsBuilder } from './data/localized-challenges-attachments.js';
import { staticCoursesBuilder } from './data/static-courses.js';
import { whitelistedUrlsBuilder } from './data/whitelisted-urls.js';
import { translationsBuilder } from './data/translations.js';
import { buildMissions } from './data/missions.js';
export async function seed(knex) {
const databaseBuilder = new DatabaseBuilder({ knex });
const adminId = databaseBuilder.factory.buildUser({
trigram: 'DEV',
name: 'Utilisateur pour le développement',
access: 'admin',
apiKey: process.env.REVIEW_APP_ADMIN_USER_API_KEY || adminUserApiKey,
}).id;
databaseBuilder.factory.buildUser({
trigram: 'EDI',
name: 'Editeur pour le développement',
access: 'editor',
apiKey: process.env.REVIEW_APP_EDITOR_USER_API_KEY || defaultEditorUserApiKey,
});
databaseBuilder.factory.buildUser({
trigram: 'RPO',
name: 'Lecteur pix pour le développement',
access: 'readpixonly',
apiKey: process.env.REVIEW_APP_READ_PIX_ONLY_USER_API_KEY || readPixOnlyUserApiKey,
});
databaseBuilder.factory.buildUser({
trigram: 'LOL',
name: 'Lecteur TOUT pour le développement',
access: 'readonly',
apiKey: process.env.REVIEW_APP_READ_ONLY_USER_API_KEY || readOnlyUserApiKey,
});
const translations = await translationsBuilder(databaseBuilder);
await localizedChallengesBuilder(databaseBuilder, translations);
await localizedChallengesAttachmentsBuilder(databaseBuilder);
staticCoursesBuilder(databaseBuilder);
buildMissions(databaseBuilder);
whitelistedUrlsBuilder(databaseBuilder, adminId);
return databaseBuilder.commit();
}
const adminUserApiKey = !process.env.REVIEW_APP && '8d03a893-3967-4501-9dc4-e0aa6c6dc442';
const defaultEditorUserApiKey = !process.env.REVIEW_APP && 'adaf3eee-09dc-4f9a-a504-ff92e74c9d0f';
const readPixOnlyUserApiKey = !process.env.REVIEW_APP && '09ae36c4-11e1-4212-ae51-e5719d142f57';
const readOnlyUserApiKey = !process.env.REVIEW_APP && '3b234506-e31e-45eb-a56e-17f64f31ca1b';