Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow #6

Open
siddukp opened this issue Sep 28, 2019 · 0 comments
Open

Flow #6

siddukp opened this issue Sep 28, 2019 · 0 comments

Comments

@siddukp
Copy link

siddukp commented Sep 28, 2019

Customer signup with email id and password(CommonDb.users id:1 email: bansal@flipkart.com )
POST /api//users

const mainDomain = 'tenantapp.com';
const linodeIp = '120.120.120.120'
// either we can use this function of we can keep *.tenantapp.com -> 120.120.120.120
// linode centos server with ip 120.120.120.120
const createDNS = (subdomain) => {
  rp({
    url: `https://api.digitalocean.com/api/domains/${mainDomain}/A`,
    method: POST',
    body: { subdomain, ip: linodeIp }
  })
}

export async function create(req, res, next) {
  const user = await CommonDb.User.create({ email: req.body.email }); // id:1
  const domain = req.body.email.split('@')[1];
  const subdomain = domain.split('.')[0];

  const project = 'nps_feedback';
  const connectionString = await MySQLApi.createDb(`${subdomain}_${project}`);

  const client = await CommonDb.Client.create({ user_id: user.id, name:  subdomain, connectionString   });
  await SequelizeApi.migrateDb(connectionString);
  await SequelizeApi.seedDb(connectionString);

  // all subdomains pointing to one machine as wildcard dns entry
  user.update({ client_id: client.id });
  res.json({ message: 'Signup successful, Provisioning done from http://${subdomain}.${mainDomain}'})

}
domain: flipkart.tenantapp.com


1. dbinfo = DB Creation Script
2. dbId = saveDbInfoToCommonDbClientsTable(dbInfo)
3. 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant