@@ -20,10 +20,11 @@ exports.handler = async function () {
2020 console . log ( 'Starting setup' )
2121 console . log ( 'If unsure, use default' )
2222 const { siteHost, port, sessionName, sessionDomain, contactEmail } = await inquirer . prompt (
23- [ { type : 'input' , name : 'siteHost' , message : 'BanManager UI Site Hostname' , default : 'http://localhost:3000' } ,
23+ [ { type : 'input' , name : 'siteHost' , message : 'BanManager UI Site Hostname' , default : 'http://localhost:3000' } ,
2424 { type : 'input' , name : 'port' , message : 'Port to run API' , default : 3001 } ,
2525 { type : 'input' , name : 'sessionName' , message : 'Cookie session name' , default : 'bm-ui-sess' } ,
26- { type : 'input' ,
26+ {
27+ type : 'input' ,
2728 name : 'sessionDomain' ,
2829 message : 'Top level cookie session domain e.g. frostcast.net' ,
2930 default : 'localhost'
@@ -34,7 +35,7 @@ exports.handler = async function () {
3435 const sessionKey = await crypto . createKey ( ) . toString ( 'hex' )
3536 const { publicKey, privateKey } = generateVAPIDKeys ( )
3637 const dbQuestions =
37- [ { type : 'input' , name : 'host' , message : 'Database Host' , default : '127.0.0.1' } ,
38+ [ { type : 'input' , name : 'host' , message : 'Database Host' , default : '127.0.0.1' } ,
3839 { type : 'input' , name : 'port' , message : 'Database Port' , default : 3306 } ,
3940 { type : 'input' , name : 'user' , message : 'Database User' } ,
4041 { type : 'password' , name : 'password' , message : 'Database Password' } ,
@@ -47,7 +48,8 @@ exports.handler = async function () {
4748 console . log ( 'Setting up database...' )
4849
4950 const dbConfig =
50- { ...dbAnswers ,
51+ {
52+ ...dbAnswers ,
5153 driver : 'mysql' ,
5254 connectionLimit : 1 ,
5355 multipleStatements : true
@@ -90,15 +92,15 @@ exports.handler = async function () {
9092
9193 console . log ( 'Setup your admin user' )
9294
93- const { email } = await inquirer . prompt ( [ { name : 'email' , message : 'Your email address' } ] )
95+ const { email } = await inquirer . prompt ( [ { name : 'email' , message : 'Your email address' } ] )
9496 const password = await askPassword ( )
9597 const playerId = await askPlayerAccount ( 'Your Minecraft Player UUID' , conn , serverConn , serverTables . players )
9698 const user = {
97- email, password, ' player_id' : playerId , updated : Math . floor ( Date . now ( ) / 1000 )
99+ email, password, player_id : playerId , updated : Math . floor ( Date . now ( ) / 1000 )
98100 }
99101
100102 await udify . insert ( conn , 'bm_web_users' , user )
101- await udify . insert ( conn , 'bm_web_player_roles' , { ' player_id' : playerId , ' role_id' : 3 } )
103+ await udify . insert ( conn , 'bm_web_player_roles' , { player_id : playerId , role_id : 3 } )
102104
103105 console . log ( `Account created, start the application and login via ${ siteHost } /login` )
104106
@@ -143,7 +145,7 @@ DB_CONNECTION_LIMIT=5
143145
144146async function askPassword ( ) {
145147 const { password, vPass } = await inquirer . prompt (
146- [ { type : 'password' , name : 'password' , message : 'Password' } ,
148+ [ { type : 'password' , name : 'password' , message : 'Password' } ,
147149 { type : 'password' , name : 'vPass' , message : 'Confirm Password' }
148150 ] )
149151
@@ -169,7 +171,8 @@ async function promptServerDetails () {
169171
170172 try {
171173 db =
172- { host,
174+ {
175+ host,
173176 port,
174177 user,
175178 password,
@@ -186,7 +189,7 @@ async function promptServerDetails () {
186189
187190 const serverTables = { }
188191
189- for ( let table of tables ) {
192+ for ( const table of tables ) {
190193 const tableName = await promptTable ( conn , table )
191194
192195 serverTables [ table ] = tableName
@@ -196,7 +199,7 @@ async function promptServerDetails () {
196199}
197200
198201async function promptTable ( conn , table ) {
199- const { tableName } = await inquirer . prompt ( [ { name : 'tableName' , message : `${ table } table name` } ] )
202+ const { tableName } = await inquirer . prompt ( [ { name : 'tableName' , message : `${ table } table name` } ] )
200203
201204 try {
202205 await checkTable ( conn , tableName )
@@ -211,9 +214,9 @@ async function promptTable (conn, table) {
211214}
212215
213216async function checkTable ( conn , table ) {
214- const [ [ { exists } ] ] = await conn . execute (
217+ const [ [ { exists } ] ] = await conn . execute (
215218 'SELECT COUNT(*) AS `exists` FROM information_schema.tables WHERE table_schema = ? AND table_name = ?'
216- , [ conn . connection . config . database , table ] )
219+ , [ conn . connection . config . database , table ] )
217220
218221 if ( ! exists ) {
219222 throw new Error ( 'Could not find table ' + table )
@@ -222,13 +225,13 @@ async function checkTable (conn, table) {
222225
223226// { type: 'input', name: 'name', message: 'Server Name', default: 'Frostcast' }
224227async function askPlayer ( question , conn , table ) {
225- const questions = [ { name : 'id' , message : question } ]
228+ const questions = [ { name : 'id' , message : question } ]
226229 const { id } = await inquirer . prompt ( questions )
227230 const parsedId = parse ( id , Buffer . alloc ( 16 ) )
228231
229- const [ [ result ] ] = await conn . query (
232+ const [ [ result ] ] = await conn . query (
230233 'SELECT name FROM ?? WHERE id = ?'
231- , [ table , parsedId ] )
234+ , [ table , parsedId ] )
232235
233236 if ( ! result ) {
234237 console . log ( `Could not find Player ${ id } ` )
@@ -243,9 +246,9 @@ async function askPlayer (question, conn, table) {
243246async function askPlayerAccount ( question , conn , serverConn , table ) {
244247 const id = await askPlayer ( question , serverConn , table )
245248
246- const [ [ { exists } ] ] = await conn . execute (
249+ const [ [ { exists } ] ] = await conn . execute (
247250 'SELECT COUNT(*) AS `exists` FROM bm_web_users WHERE player_id = ?'
248- , [ id ] )
251+ , [ id ] )
249252
250253 if ( exists ) {
251254 console . error ( 'An account already exists for that player' )
0 commit comments