From 44e6fd31d2fa7761c90ff1d6932cf69d163b22e8 Mon Sep 17 00:00:00 2001 From: Pitu Date: Thu, 21 Feb 2019 23:49:29 +0900 Subject: Database migration and seeding --- src/api/database/seeds/initial.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/api/database/seeds/initial.js (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js new file mode 100644 index 0000000..d4a343c --- /dev/null +++ b/src/api/database/seeds/initial.js @@ -0,0 +1,32 @@ +const bcrypt = require('bcrypt'); +const moment = require('moment'); +const randomstring = require('randomstring'); + +exports.seed = async db => { + const now = moment.utc().toDate(); + const user = await db.table('users').where({ username: 'root' }).first(); + if (user) return; + try { + const hash = await bcrypt.hash(process.env.ADMIN_PASSWORD, 10); + await db.table('users').insert({ + username: process.env.ADMIN_ACCOUNT, + password: hash, + apiKey: randomstring.generate(64), + passwordEditedAt: now, + apiKeyEditedAt: now, + createdAt: now, + editedAt: now, + isAdmin: true + }); + console.log(); + console.log('===================================================='); + console.log('== Successfully created the admin account. =='); + console.log('===================================================='); + console.log('== Run `yarn api` and `yarn site` next =='); + console.log('== preferably with pm2 or tmux to keep them alive =='); + console.log('===================================================='); + console.log(); + } catch (error) { + console.error(error); + } +} -- cgit v1.2.3 From fc95cb7b0f047806937c25f0fc1104c72b0a32cb Mon Sep 17 00:00:00 2001 From: Pitu Date: Sat, 23 Feb 2019 00:45:45 +0900 Subject: Better DB handling and stuff --- src/api/database/seeds/initial.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index d4a343c..7445916 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -16,6 +16,7 @@ exports.seed = async db => { apiKeyEditedAt: now, createdAt: now, editedAt: now, + enabled: true, isAdmin: true }); console.log(); -- cgit v1.2.3 From b1e751159339bca98b5d878802147cb318e113d0 Mon Sep 17 00:00:00 2001 From: Pitu Date: Tue, 12 Mar 2019 08:17:37 +0000 Subject: What are strings even --- src/api/database/seeds/initial.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 7445916..0ea7bb4 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -20,12 +20,11 @@ exports.seed = async db => { isAdmin: true }); console.log(); - console.log('===================================================='); - console.log('== Successfully created the admin account. =='); - console.log('===================================================='); - console.log('== Run `yarn api` and `yarn site` next =='); - console.log('== preferably with pm2 or tmux to keep them alive =='); - console.log('===================================================='); + console.log('========================================================='); + console.log('== Successfully created the admin account. =='); + console.log('========================================================='); + console.log('== Run `pm2 start pm2.json` to start the service =='); + console.log('========================================================='); console.log(); } catch (error) { console.error(error); -- cgit v1.2.3 From 107d1f4750e8f82a628b528c4ec200e918be271d Mon Sep 17 00:00:00 2001 From: Pitu Date: Tue, 19 Mar 2019 07:58:36 +0000 Subject: API key WIP --- src/api/database/seeds/initial.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 0ea7bb4..bb8b915 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -11,9 +11,7 @@ exports.seed = async db => { await db.table('users').insert({ username: process.env.ADMIN_ACCOUNT, password: hash, - apiKey: randomstring.generate(64), passwordEditedAt: now, - apiKeyEditedAt: now, createdAt: now, editedAt: now, enabled: true, -- cgit v1.2.3 From a552aca8ab67535bf025c6f06f751a0b11ef2e9a Mon Sep 17 00:00:00 2001 From: Pitu Date: Tue, 1 Oct 2019 14:08:43 -0300 Subject: chore: Remove unnecesary stuff --- src/api/database/seeds/initial.js | 1 - 1 file changed, 1 deletion(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index bb8b915..560b6b2 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -1,6 +1,5 @@ const bcrypt = require('bcrypt'); const moment = require('moment'); -const randomstring = require('randomstring'); exports.seed = async db => { const now = moment.utc().toDate(); -- cgit v1.2.3 From 391ee68e4a67aec640e25bc3506f9e31c77e58f5 Mon Sep 17 00:00:00 2001 From: Pitu Date: Sat, 12 Oct 2019 15:47:25 +0900 Subject: chore: Upgrade buefy to newest version --- src/api/database/seeds/initial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 560b6b2..bb4ce8c 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -26,4 +26,4 @@ exports.seed = async db => { } catch (error) { console.error(error); } -} +}; -- cgit v1.2.3 From bca8fbcd839d2239e3f6f141f662fbbc74726835 Mon Sep 17 00:00:00 2001 From: Pitu Date: Sat, 12 Oct 2019 21:14:19 +0900 Subject: refactor: removed useless code, cleaned up, fixed permissions --- src/api/database/seeds/initial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index bb4ce8c..280fd74 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -3,7 +3,7 @@ const moment = require('moment'); exports.seed = async db => { const now = moment.utc().toDate(); - const user = await db.table('users').where({ username: 'root' }).first(); + const user = await db.table('users').where({ username: process.env.ADMIN_ACCOUNT }).first(); if (user) return; try { const hash = await bcrypt.hash(process.env.ADMIN_PASSWORD, 10); -- cgit v1.2.3 From de54e19d3a102cad6364a6f9f50dab48c2367683 Mon Sep 17 00:00:00 2001 From: Pitu Date: Sun, 10 May 2020 00:03:45 +0900 Subject: chore: remove the use of uuid --- src/api/database/seeds/initial.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 280fd74..5e906fb 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -1,5 +1,6 @@ const bcrypt = require('bcrypt'); const moment = require('moment'); +const uuidv4 = require('uuid/v4'); exports.seed = async db => { const now = moment.utc().toDate(); @@ -8,6 +9,7 @@ exports.seed = async db => { try { const hash = await bcrypt.hash(process.env.ADMIN_PASSWORD, 10); await db.table('users').insert({ + uuid: uuidv4(), username: process.env.ADMIN_ACCOUNT, password: hash, passwordEditedAt: now, -- cgit v1.2.3 From 432d86022c5bf31403bc55607c6b0f1a7191e4ca Mon Sep 17 00:00:00 2001 From: Pitu Date: Sun, 10 May 2020 00:39:53 +0900 Subject: chore: forgot to remove this uuid --- src/api/database/seeds/initial.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 5e906fb..280fd74 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -1,6 +1,5 @@ const bcrypt = require('bcrypt'); const moment = require('moment'); -const uuidv4 = require('uuid/v4'); exports.seed = async db => { const now = moment.utc().toDate(); @@ -9,7 +8,6 @@ exports.seed = async db => { try { const hash = await bcrypt.hash(process.env.ADMIN_PASSWORD, 10); await db.table('users').insert({ - uuid: uuidv4(), username: process.env.ADMIN_ACCOUNT, password: hash, passwordEditedAt: now, -- cgit v1.2.3 From ad852de51a0d2dd5d29c08838d5a430c58849e74 Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Wed, 8 Jul 2020 04:00:12 +0300 Subject: chore: linter the entire project using the new rules --- src/api/database/seeds/initial.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 280fd74..cdbfa80 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -1,7 +1,8 @@ +/* eslint-disable no-console */ const bcrypt = require('bcrypt'); const moment = require('moment'); -exports.seed = async db => { +exports.seed = async (db) => { const now = moment.utc().toDate(); const user = await db.table('users').where({ username: process.env.ADMIN_ACCOUNT }).first(); if (user) return; @@ -14,7 +15,7 @@ exports.seed = async db => { createdAt: now, editedAt: now, enabled: true, - isAdmin: true + isAdmin: true, }); console.log(); console.log('========================================================='); -- cgit v1.2.3 From 90001c2df56d58e69fd199a518ae7f3e4ed327fc Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Thu, 24 Dec 2020 10:40:50 +0200 Subject: chore: remove trailing commas --- src/api/database/seeds/initial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index cdbfa80..2383a7b 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -15,7 +15,7 @@ exports.seed = async (db) => { createdAt: now, editedAt: now, enabled: true, - isAdmin: true, + isAdmin: true }); console.log(); console.log('========================================================='); -- cgit v1.2.3 From fb2c27086f570fec60f4d52dcc9ca80e53186293 Mon Sep 17 00:00:00 2001 From: Pitu Date: Thu, 24 Dec 2020 23:45:16 +0900 Subject: Fix ESLint rules once and for all --- src/api/database/seeds/initial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/api/database/seeds/initial.js') diff --git a/src/api/database/seeds/initial.js b/src/api/database/seeds/initial.js index 2383a7b..edc1949 100644 --- a/src/api/database/seeds/initial.js +++ b/src/api/database/seeds/initial.js @@ -2,7 +2,7 @@ const bcrypt = require('bcrypt'); const moment = require('moment'); -exports.seed = async (db) => { +exports.seed = async db => { const now = moment.utc().toDate(); const user = await db.table('users').where({ username: process.env.ADMIN_ACCOUNT }).first(); if (user) return; -- cgit v1.2.3