mirror of
https://github.com/pockethost/pockethost.git
synced 2025-11-23 22:15:49 +00:00
mothership: instance creation fixes
This commit is contained in:
parent
a5eaa425c7
commit
f39e49ab34
@ -77,13 +77,14 @@ var HandleInstanceCreate = (c) => {
|
||||
log(`***TOP OF POST`);
|
||||
let data = new DynamicModel({
|
||||
subdomain: "",
|
||||
version: versions[0],
|
||||
region: "sfo-2"
|
||||
});
|
||||
log(`***before bind`);
|
||||
c.bind(data);
|
||||
log(`***after bind`);
|
||||
data = JSON.parse(JSON.stringify(data));
|
||||
const { subdomain, region } = data;
|
||||
const { subdomain, version, region } = data;
|
||||
log(`***vars`, JSON.stringify({ subdomain, region }));
|
||||
if (!subdomain) {
|
||||
throw new BadRequestError(
|
||||
@ -96,7 +97,7 @@ var HandleInstanceCreate = (c) => {
|
||||
record.set("region", region || `sfo-1`);
|
||||
record.set("subdomain", subdomain);
|
||||
record.set("status", "idle");
|
||||
record.set("version", versions[0]);
|
||||
record.set("version", version);
|
||||
record.set("dev", true);
|
||||
record.set("syncAdmin", true);
|
||||
record.set("notifyMaintenanceMode", true);
|
||||
|
||||
@ -15,8 +15,9 @@ export const HandleInstanceCreate = (c: echo.Context) => {
|
||||
log(`***TOP OF POST`)
|
||||
let data = new DynamicModel({
|
||||
subdomain: '',
|
||||
version: versions[0],
|
||||
region: 'sfo-2',
|
||||
}) as { subdomain?: string; region?: string }
|
||||
}) as { subdomain?: string; version?: string; region?: string }
|
||||
|
||||
log(`***before bind`)
|
||||
|
||||
@ -27,7 +28,7 @@ export const HandleInstanceCreate = (c: echo.Context) => {
|
||||
// This is necessary for destructuring to work correctly
|
||||
data = JSON.parse(JSON.stringify(data))
|
||||
|
||||
const { subdomain, region } = data
|
||||
const { subdomain, version, region } = data
|
||||
|
||||
log(`***vars`, JSON.stringify({ subdomain, region }))
|
||||
|
||||
@ -43,7 +44,7 @@ export const HandleInstanceCreate = (c: echo.Context) => {
|
||||
record.set('region', region || `sfo-1`)
|
||||
record.set('subdomain', subdomain)
|
||||
record.set('status', 'idle')
|
||||
record.set('version', versions[0])
|
||||
record.set('version', version)
|
||||
record.set('dev', true)
|
||||
record.set('syncAdmin', true)
|
||||
record.set('notifyMaintenanceMode', true)
|
||||
|
||||
@ -19,6 +19,7 @@ export const HandleSignupConfirm = (c: echo.Context) => {
|
||||
const password = parsed.password?.trim()
|
||||
const desiredInstanceName = parsed.instanceName?.trim()
|
||||
const region = parsed.region?.trim()
|
||||
const version = parsed.version?.trim() || versions[0]
|
||||
|
||||
if (!email) {
|
||||
throw error(`email`, 'required', 'Email is required')
|
||||
@ -64,7 +65,6 @@ export const HandleSignupConfirm = (c: echo.Context) => {
|
||||
user.set('username', username)
|
||||
user.set('email', email)
|
||||
user.set('subscription', 'free')
|
||||
user.set('notifyMaintenanceMode', true)
|
||||
user.setPassword(password)
|
||||
txDao.saveRecord(user)
|
||||
} catch (e) {
|
||||
@ -74,13 +74,12 @@ export const HandleSignupConfirm = (c: echo.Context) => {
|
||||
try {
|
||||
const instance = new Record(instanceCollection)
|
||||
instance.set('subdomain', desiredInstanceName)
|
||||
instance.set('region', region || `sfo-1`)
|
||||
instance.set('region', region || `sfo-2`)
|
||||
instance.set('uid', user.get('id'))
|
||||
instance.set('status', 'idle')
|
||||
instance.set('notifyMaintenanceMode', true)
|
||||
instance.set('syncAdmin', true)
|
||||
instance.set('dev', true)
|
||||
instance.set('version', versions[0])
|
||||
instance.set('version', version)
|
||||
txDao.saveRecord(instance)
|
||||
} catch (e) {
|
||||
if (`${e}`.match(/ UNIQUE /)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user