2017-05-03 22:48:15 +03:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-05 23:54:44 +03:00
|
|
|
const Data = require('portal-data');
|
2017-05-03 22:48:15 +03:00
|
|
|
|
|
|
|
|
2017-06-05 23:54:44 +03:00
|
|
|
const ifError = function (err) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-06-09 21:13:22 +03:00
|
|
|
const bootstrap = function () {
|
|
|
|
const data = new Data();
|
2017-06-05 23:54:44 +03:00
|
|
|
|
2017-06-09 21:13:22 +03:00
|
|
|
data.connect(() => {
|
|
|
|
data.createDatacenter({ region: 'us-sw', name: 'us-sw' }, (err, datacenter) => {
|
2017-06-05 23:54:44 +03:00
|
|
|
ifError(err);
|
|
|
|
|
2017-06-09 21:13:22 +03:00
|
|
|
data.createUser({ firstName: 'Nikola', lastName: 'Tesla', email: 'nikola@tesla.com', login: 'nikola' }, (err, user) => {
|
2017-06-05 23:54:44 +03:00
|
|
|
ifError(err);
|
|
|
|
|
2017-06-09 21:13:22 +03:00
|
|
|
data.createPortal({
|
|
|
|
user,
|
|
|
|
datacenter
|
|
|
|
}, (err, portal) => {
|
2017-06-05 23:54:44 +03:00
|
|
|
ifError(err);
|
|
|
|
console.log('data bootstrapped');
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
});
|
2017-05-03 22:48:15 +03:00
|
|
|
});
|
|
|
|
});
|
2017-06-09 21:13:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const main = function () {
|
|
|
|
const dropData = new Data();
|
|
|
|
|
|
|
|
dropData.connect(() => {
|
|
|
|
dropData._db.r.dbDrop('portal').run(dropData._db._connection, () => {
|
|
|
|
bootstrap();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
main();
|