Skip to content

Commit

Permalink
Introduce production collection types, fix test users
Browse files Browse the repository at this point in the history
  • Loading branch information
blokhin committed Sep 6, 2023
1 parent 0e894ec commit 31c165c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 44 deletions.
34 changes: 22 additions & 12 deletions db/seeds/010-collections-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,34 @@ exports.seed = async function (knex) {
await knex(COLLECTIONS_TYPES_TABLE).del();
await knex(COLLECTIONS_TYPES_TABLE).insert([
{
slug: 'red',
label: 'Red',
flavor: 'red',
// id = 1
slug: 'requests',
label: 'Requests',
flavor: '#900',
},
{
slug: 'blue',
label: 'Blue',
flavor: 'blue',
// id = 2
slug: 'samples',
label: 'Samples',
flavor: '#ccc',
},
{
slug: 'green',
label: 'Green',
flavor: 'green',
// id = 3
slug: 'statuses',
label: 'Statuses',
flavor: '#fff',
},
{
slug: 'orange',
label: 'Orange',
flavor: 'orange',
// id = 4
slug: 'phases',
label: 'Materials',
flavor: '#666',
},
{
// id = 5
slug: 'customers',
label: 'Customers',
flavor: '#5755D9',
},
]);
};
13 changes: 0 additions & 13 deletions db/seeds/030-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ exports.seed = async function (knex) {
roleId: adminRole.id,
password,
},
{
firstName: 'Test',
lastName: 'Test',
roleId: memberRole.id,
password,
},
],
['id']
);
Expand All @@ -49,11 +43,9 @@ exports.seed = async function (knex) {

const memberEmail = '[email protected]';
const adminEmail = '[email protected]';
const testEmail = '[email protected]';

const code1 = await hashString(memberEmail);
const code2 = await hashString(adminEmail);
const code3 = await hashString(testEmail);

await knex(USERS_EMAILS_TABLE).insert([
{
Expand All @@ -66,10 +58,5 @@ exports.seed = async function (knex) {
email: adminEmail,
code: code2,
},
{
userId: test.id,
email: testEmail,
code: code3,
},
]);
};
5 changes: 3 additions & 2 deletions routes/[version]/apikey.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ const crypto = require('crypto');
const { checkAuth } = require('../../middlewares/auth');
const { selectAPIToken, setAPIToken, removeAPIToken } = require('../../services/db');

const generateAPIToken = (length = 11) => 'METIS_' + crypto.randomBytes(length).toString('hex'); // 28 chars

module.exports = {
get: [checkAuth, get],
put: [checkAuth, put],
delete: [checkAuth, del],
generateAPIToken,
};

const generateAPIToken = (length = 11) => 'METIS_' + crypto.randomBytes(length).toString('hex'); // 28 chars

/**
* @api {put} /v0/apikey Create new API key
* @apiName SetAPIKey
Expand Down
20 changes: 3 additions & 17 deletions services/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,15 @@ const ADMIN_USER_ROLE = 'admin';
const PUBLIC_COLLECTION_VISIBILITY = 'community';
const SHARED_COLLECTION_VISIBILITY = 'shared';
const PRIVATE_COLLECTION_VISIBILITY = 'private';

const OAUTH_PROVIDERS_ENUM = ['dummy', 'github', 'linkedin', 'orcid', 'mpds', 'basf'];
const FLAVORS_ENUM = [
'red',
'pink',
'purple',
'indigo',
'blue',
'cyan',
'teal',
'green',
'lime',
'yellow',
'orange',
'brown',
'grey',
];
const VISIBILITY_ENUM = [
PRIVATE_COLLECTION_VISIBILITY,
SHARED_COLLECTION_VISIBILITY,
PUBLIC_COLLECTION_VISIBILITY,
];

const OAUTH_PROVIDERS_ENUM = ['dummy', 'github', 'linkedin', 'orcid', 'mpds', 'basf'];
const FLAVORS_ENUM = ['#900', '#ccc', '#fff', '#666', '#5755D9'];

const selectDataSourcesByUserId = selectAllByUserId(USER_DATASOURCES_TABLE, DATASOURCE_FIELDS);
const selectCalculationsByUserId = selectAllByUserId(USER_CALCULATIONS_TABLE);
const deleteUserDataSource = deleteFirstByUserId(USER_DATASOURCES_TABLE);
Expand Down

0 comments on commit 31c165c

Please sign in to comment.