mirror of
https://github.com/wassname/talk.git
synced 2026-07-31 12:50:48 +08:00
Added new setup endpoint
This commit is contained in:
@@ -9,6 +9,39 @@ const errors = require('../errors');
|
||||
*/
|
||||
module.exports = class SetupService {
|
||||
|
||||
/**
|
||||
* This returns a promise which resolves if the setup is available.
|
||||
*/
|
||||
static isAvailable() {
|
||||
|
||||
// Check if we have an install lock present.
|
||||
if (process.env.TALK_INSTALL_LOCK === 'TRUE') {
|
||||
return Promise.reject(errors.ErrInstallLock);
|
||||
}
|
||||
|
||||
// Get the current settings, we are expecing an error here.
|
||||
return SettingsService
|
||||
.retrieve()
|
||||
.then(() => {
|
||||
|
||||
// We should NOT have gotten a settings object, this means that the
|
||||
// application is already setup. Error out here.
|
||||
return Promise.reject(errors.ErrSettingsInit);
|
||||
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
// If the error is `not init`, then we're good, otherwise, it's something
|
||||
// else.
|
||||
if (err !== errors.ErrSettingsNotInit) {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
// Allow the request to keep going here.
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This verifies that the current input for the setup is valid.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user