@axium/server 0.4.7 → 0.4.8
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/dist/cli.js +1 -6
- package/dist/database.js +9 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -45,12 +45,7 @@ axiumDB
|
|
|
45
45
|
.addOption(opts.force)
|
|
46
46
|
.option('-s, --skip', 'Skip existing database and/or user')
|
|
47
47
|
.action(async (opt) => {
|
|
48
|
-
await db.init(opt).catch(
|
|
49
|
-
if (typeof e == 'number')
|
|
50
|
-
process.exit(e);
|
|
51
|
-
else
|
|
52
|
-
exit(e);
|
|
53
|
-
});
|
|
48
|
+
await db.init(opt).catch(handleError);
|
|
54
49
|
});
|
|
55
50
|
axiumDB
|
|
56
51
|
.command('status')
|
package/dist/database.js
CHANGED
|
@@ -108,6 +108,7 @@ export async function init(opt) {
|
|
|
108
108
|
}
|
|
109
109
|
const _sql = (command, message) => run(opt, message, `sudo -u postgres psql -c "${command}"`);
|
|
110
110
|
const relationExists = someWarnings(opt.output, [/relation "\w+" already exists/, 'already exists.']);
|
|
111
|
+
const done = () => opt.output('done');
|
|
111
112
|
await _sql('CREATE DATABASE axium', 'Creating database').catch(async (error) => {
|
|
112
113
|
if (error != 'database "axium" already exists')
|
|
113
114
|
throw error;
|
|
@@ -143,8 +144,8 @@ export async function init(opt) {
|
|
|
143
144
|
.addColumn('salt', 'text')
|
|
144
145
|
.addColumn('preferences', 'jsonb', col => col.notNull().defaultTo(sql `'{}'::jsonb`))
|
|
145
146
|
.execute()
|
|
147
|
+
.then(done)
|
|
146
148
|
.catch(relationExists);
|
|
147
|
-
opt.output('done');
|
|
148
149
|
opt.output('start', 'Creating table Account');
|
|
149
150
|
await db.schema
|
|
150
151
|
.createTable('Account')
|
|
@@ -161,11 +162,10 @@ export async function init(opt) {
|
|
|
161
162
|
.addColumn('id_token', 'text')
|
|
162
163
|
.addColumn('session_state', 'text')
|
|
163
164
|
.execute()
|
|
165
|
+
.then(done)
|
|
164
166
|
.catch(relationExists);
|
|
165
|
-
opt.output('done');
|
|
166
167
|
opt.output('start', 'Creating index for Account.userId');
|
|
167
|
-
await db.schema.createIndex('Account_userId_index').on('Account').column('userId').execute().catch(relationExists);
|
|
168
|
-
opt.output('done');
|
|
168
|
+
await db.schema.createIndex('Account_userId_index').on('Account').column('userId').execute().then(done).catch(relationExists);
|
|
169
169
|
opt.output('start', 'Creating table Session');
|
|
170
170
|
await db.schema
|
|
171
171
|
.createTable('Session')
|
|
@@ -174,11 +174,10 @@ export async function init(opt) {
|
|
|
174
174
|
.addColumn('sessionToken', 'text', col => col.notNull().unique())
|
|
175
175
|
.addColumn('expires', 'timestamptz', col => col.notNull())
|
|
176
176
|
.execute()
|
|
177
|
+
.then(done)
|
|
177
178
|
.catch(relationExists);
|
|
178
|
-
opt.output('done');
|
|
179
179
|
opt.output('start', 'Creating index for Session.userId');
|
|
180
|
-
await db.schema.createIndex('Session_userId_index').on('Session').column('userId').execute().catch(relationExists);
|
|
181
|
-
opt.output('done');
|
|
180
|
+
await db.schema.createIndex('Session_userId_index').on('Session').column('userId').execute().then(done).catch(relationExists);
|
|
182
181
|
opt.output('start', 'Creating table VerificationToken');
|
|
183
182
|
await db.schema
|
|
184
183
|
.createTable('VerificationToken')
|
|
@@ -186,8 +185,8 @@ export async function init(opt) {
|
|
|
186
185
|
.addColumn('token', 'text', col => col.notNull().unique())
|
|
187
186
|
.addColumn('expires', 'timestamptz', col => col.notNull())
|
|
188
187
|
.execute()
|
|
188
|
+
.then(done)
|
|
189
189
|
.catch(relationExists);
|
|
190
|
-
opt.output('done');
|
|
191
190
|
opt.output('start', 'Creating table Authenticator');
|
|
192
191
|
await db.schema
|
|
193
192
|
.createTable('Authenticator')
|
|
@@ -200,11 +199,10 @@ export async function init(opt) {
|
|
|
200
199
|
.addColumn('credentialBackedUp', 'boolean', col => col.notNull())
|
|
201
200
|
.addColumn('transports', 'text')
|
|
202
201
|
.execute()
|
|
202
|
+
.then(done)
|
|
203
203
|
.catch(relationExists);
|
|
204
|
-
opt.output('done');
|
|
205
204
|
opt.output('start', 'Creating index for Authenticator.credentialID');
|
|
206
|
-
await db.schema.createIndex('Authenticator_credentialID_key').on('Authenticator').column('credentialID').execute().catch(relationExists);
|
|
207
|
-
opt.output('done');
|
|
205
|
+
await db.schema.createIndex('Authenticator_credentialID_key').on('Authenticator').column('credentialID').execute().then(done).catch(relationExists);
|
|
208
206
|
return config.db;
|
|
209
207
|
}
|
|
210
208
|
catch (e_1) {
|