cross domain relation - dns

suppose I have www.usa.com as main site. I will create www.utah.com..www.indiana.com...etc on same dedicated server with same hosting. After creating those usa-state sites I will register users from www.usa.com and place them under different states and will give them their own site like www.utah.com/andy . Here user Andy was registered from www.usa.com but placed under www.utah.com. If I search user Andy from www.utah.com or www.usa.com i can get his details but i cant get his details from www.indiana.com.
how i can achieve the above like registered from one site but placed in another site? do u recommend one database-multiple domain concept? how should i approach to built this type of application? pls help

From your description it sounds more like your application (as a single app) would be logically organized like this:
usa.com
usa.com/utah
usa.com/utah/andy
usa.com/indiana
...
You could use separate domains for the states through some URL rewriting to achieve what you want. Your application would handle the search logic.
-OR-
The alternative is to setup each site as it's own application. The usa site would just be configured to search each of the state sites (via a query string maybe) and aggregate the results.
I know there are other ways to setup what you are looking for but I think these are probably the two major alternatives.

Related

How to: allow users to create their on pages on web app?

I'm relatively new to webdev, and essentially I'm trying to create functionality that allows users to create their own event pages (similar to Facebook Events, Meetup etc.).
My question is to do with the surrounding architecture of this, namely:
Given each event page will have its own url, do you need a separate file for each event in the backend?
Or is there some clever way of templating and directing traffic? (Sorry if this is vague, I'm trying to probe if there is a better way of doing this?)
I notice that most of the FB/Meetup events all have their own URLs, does this mean that they all have separate files in the backend?
I'm using Nodejs for the backend btw.
I've been Googling around but haven't been able to figure it out, I think I might be using the wrong wording... so even a point in the direction of the right wording would be much appreciated!
Thanks y'all
Generally this is handled via database-driven solutions. The "pages" are dynamic, and the URL is a parameter see #Konrad's comment that allows the pages to be looked up in a database which allows the dynamic content to be loaded into a single page which handles the complexity of each page seeming unique.

Redirect to a specific link routing

i'm using express to make a electronic document management (EDMS) in node.js.
After the user login, I'll have a simple box, where he's chosee between two options:
a. search XML files
b. search Other Documents files
is there a way to create specific routing for, if he chooses to go only with XML, all links i'll be under that routing?
Something like xml/home/ and otherDocuments/home/ and the rest of the methods ill be xml/something and otherDocuments/something?

Web application (API and Front-end) - routes design

I suppose this type of topics always exist, but i like to have an specifics opinion for my case.
Since 1/2 month i'm thinking about make a listing web application for my daily life (shopping, due, etc.)
I started out define my object model like this (very simple design model)
Models image
So, i decid to create a NodeJS API for back-end, and Angular 7 for front-end. It's not a technical problem for me to develop the application and the API, but my problem is in the design of this, and particuly to the routes design.
My first suggestion for routes API is :
User :
/users
/users/:id
List :
/lists
/lists/:id
Element :
/elements
/elements/:id
Technicaly it's ok, but i'm not sure it's the good practices.
As User contains List and List contains Element, Wouldn't it be better to have routes like this :
/users/:id
/users/:id/list
/users/:id/list/:id
/users/:id/list/:id/element
/users/:id/list/:id/element/:id
Thanks for your answers, or suggestions !
PS : If you have any web sites / video / topics ... to suggests, do not hesitate.
I'd say you got it OK in the first place, the second approach is messy as you can get huge routes, and you're sending a lot unnecesary data. Why do you need the user id to get an element? An element is an entity by itself, and it will probably grow, you may need to get related elements, filter them... its better to just have /elements
What you can do is find simple relations, like:
/users/:id/lists
/lists/:id/elements
I'd recommend reading building apis you won't hate :)
Firstly you are in absolute correct path of defining Routes in angular, at the same time you have to use Lazy loading concept of Routing.
I would recommend you to, go for plural sight course , by Deborah Kurata. I'm not trying to promote or advertise anything but for your current situation that course would be the right guidance. It would provide you all the necessary things that you need to build enterprise ready apps.
Alternatively Core UI Angular provides some best designs which are already implemented with Angular Route and things. Lazy loading and other Angular routing are implemented, all you need to do is understand it.
Hope this helps.,
Principle
as short as possible
easy to read
user-friendly input when the user enters the URL
Examples
User list
/users
User detail
/user/:id
Add user
/user/new
User's functional page
/user/:id/tel

Best Practice Advice - Loopback API

I want to make a webservice and it looks like Loopback is good starting point.
To explain my question, I will describe situation
I have 2 MySQL Tables:
Users
Companies
Every User has it's Company. It's like master User for it's company.
I wish to create Products table for each company next way:
company1_Products,
company2_Products,
company3_Products
Each company have internal Users, like:
company1_Users,
company2_Users,
company3_Users
Internal users are logging in from corresponding subdomain, like
company1.myservice.com
company2.myservice.com
For the API, I want datasource to get Products from the corresponding table. So the question is, how to change datasource dynamically?
And how to handle Users? Storing in one table is not good, because internal company users could be in different companies...
Maybe there's better way to do such models?
Disclaimer: I am co-author and one of current maintainers of LoopBack.
how to change datasource dynamically?
The following StackOverflow answer describes a solution how to attach a single model (e.g. Product) to multiple datasources: https://stackoverflow.com/a/28327323/69868 This solution would work if you were creating one MySQL database per company instead of using company's name as the prefix of Product table name.
To achieve what you described, you can use model subclassing. For each company, define a new company-specific Product model inheriting from the shared Product model and changing the table name.
// common/models/company1-product.json
{
"name": "Company1_Product",
"base": "Product",
"mysql": {
"tableName": "company1_Products"
}
// etc.
}
You can even create these models on the fly using app.registry.createModel() and app.model() APIs, and then run dataSource.autoupdate to create SQL tables for the new model(s).
And how to handle Users? Storing in one table is not good, because internal company users could be in different companies...
I suppose you can use the same approach as you do for Products and as you described in your question.
Maybe there's better way to do such models?
The problem you are facing is calling multi-tenancy. I am afraid we haven't figured out an easy to use solution yet. There are many possible ways how to implement multi-tenancy.
For example, you can create one LoopBack application for each Company (tenant) and then create a top-level LoopBack or Express application to route incoming requests to appropriate tenant-specific LB app instance. See the following repository for a proof-of-concept implementation: https://github.com/strongloop/loopback-multitenant-poc

Implement Multi-tenancy in Loopback

We are already using loopback as our backend server for REST APIs.
Now our product demands to have multi tenancy in our system i.e seperate database per user.
So after searching for an hour , we got something like Loopback-MultiTenancy POC Sample.
The sample looks nice and exact what we need , though there are some issues we are facing using this poc and also at architecture level.
This POC create seperate folders per tenant. Each tenant folder has its own config , own datasource and its own models ,which is fine. But what we have is , we have common models for all users.
So whenever new user gets created , will have to create new tenant folder and move all models inside that folder either manually or using some script.
But when we gonna have 100 of users and say we want to change a particular model schema , so what it requires is reflect the changes in all other tenant folders also, Which is kind of very very troublesome for us.
So we are looking for better solution which doesnt ask for duplication and also serves the purpose , as of loopback.
We are kind of stuck , need some help or advice.
Thanks,

Resources