@bigbinary/neeto-custom-domains-frontend
v3.1.16
Published
A repo acts as the source of truth for the new nanos structure, configs, data etc.
Readme
neeto-custom-domains-nano
The neeto-custom-domains-nano manages custom domains across neeto
applications.
Contents
Development with Host application
The engine provides the backend setup for neetoCustomDomains.
Installation
- Add this line to your application's Gemfile:
source "NEETO_GEM_SERVER_URL" do
# ... existing gems
gem "neeto-custom-domains-engine"
end- And then execute:
bundle install- Run migrations
rails neeto_custom_domains_engine:install:migrations
rails db:migrateUsage
- Add association
# If custom domain is associated to Organization
class Organization > ApplicationRecord
has_many :custom_domains, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
# Optional
def primary_custom_domain
custom_domains&.where.missing(:redirection)&.first
end
end
# If custom domain is associated to other resources (eg: Site)
class Site > ApplicationRecord
has_many :custom_domains, as: :custom_domainable, class_name: "NeetoCustomDomainsEngine::Domain", dependent: :destroy
# Optional
def primary_custom_domain
custom_domains&.where.missing(:redirection)&.first
end
end- Add controller
All common controller logic is extracted to the engine. However, we still need to load some records from the host app controller.
class Api::V1::Admin::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
private
# If custom_domain is associated to Organization
def load_custom_domainable!
@custom_domainable = organization
end
# If custom_domain is associated to other resources (eg: site)
def load_custom_domainable!
@custom_domainable = organization.sites.find(params[:site_id])
end
end- Include the following module to your application's
config/routes.rbfile:
include NeetoCustomDomainsEngine::Routes::Draw
- Define required routes.
# config/routes.rb
custom_domains_routes :acme
# routes/api.rb within the admin routes
custom_domains_routes :domain- Add frontend component.
urlshould be the api to the custom domains controller.
import { CustomDomain as NeetoCustomDomainDashboard } from "@bigbinary/neeto-custom-domains-frontend";
import { BASE_API_V1_URL, SINGULAR } from "neetocommons/constants";
import HelpPopover from "neetomolecules/HelpPopover";
import { useTranslation } from "react-i18next";
import routes from "routes";
import { EVENTS } from "src/constants";
import { CUSTOM_DOMAIN_HELP_DOC_URL } from "src/constants/urls";
const CustomDomain = () => {
const { t } = useTranslation();
const breadcrumbs = [
{ link: routes.admin.settings.index, text: t("titles.settings") },
{
link: routes.admin.settings.customDomain,
text: t("neetoCustomDomains.customDomain", SINGULAR),
},
];
const CUSTOM_DOMAIN_DNS_PROVIDER_HELP_DOCS = {
cloudflare: {
subdomain: `${PERMANENT_URL}/permanent-url-1`,
rootDomain: `${PERMANENT_URL}/permanent-url-2`,
},
unknown: {
subdomain: `${PERMANENT_URL}/permanent-url-3`,
rootDomain: `${PERMANENT_URL}/permanent-url-4`,
},
namecheap: {
subdomain: `${PERMANENT_URL}/permanent-url-5`,
rootDomain: `${PERMANENT_URL}/permanent-url-6`,
},
hostinger: {
subdomain: `${PERMANENT_URL}/permanent-url-7`,
rootDomain: `${PERMANENT_URL}/permanent-url-8`,
},
digitalocean: {
subdomain: `${PERMANENT_URL}/permanent-url-9`,
rootDomain: `${PERMANENT_URL}/permanent-url-10`,
},
godaddy: {
subdomain: `${PERMANENT_URL}/permanent-url-11`,
rootDomain: `${PERMANENT_URL}/permanent-url-12`,
},
squarespace: {
subdomain: `${PERMANENT_URL}/permanent-url-13`,
rootDomain: `${PERMANENT_URL}/permanent-url-14`,
},
wix: {
subdomain: `${PERMANENT_URL}/permanent-url-15`,
rootDomain: `${PERMANENT_URL}/permanent-url-16`,
},
porkbun: {
subdomain: `${PERMANENT_URL}/permanent-url-17`,
rootDomain: `${PERMANENT_URL}/permanent-url-18`,
},
networksolutions: {
subdomain: `${PERMANENT_URL}/permanent-url-19`,
rootDomain: `${PERMANENT_URL}/permanent-url-20`,
},
aws: {
subdomain: `${PERMANENT_URL}/permanent-url-21`,
rootDomain: `${PERMANENT_URL}/permanent-url-22`,
},
strato: {
subdomain: `${PERMANENT_URL}/permanent-url-23`,
rootDomain: `${PERMANENT_URL}/permanent-url-24`,
},
}
return (
<div className="w-full">
<NeetoCustomDomainDashboard
appName="appname" // Eg: `cal`, `form`
dnsHelpDocs={CUSTOM_DOMAIN_DNS_PROVIDER_HELP_DOCS}
helpDocUrl={CUSTOM_DOMAIN_HELP_DOC_URL}
subdomainPlaceholder="subdomain-placeholder" // Eg: `schedule` for NeetoCal and `form` for NeetoForm
url={`${BASE_URL}/custom-domains`}
{ ...{ breadcrumbs } }
/>
</div>
);
};
export default CustomDomain;- Mount the
CustomDomaincomponent at the desired apth.
ENV variables
For the working of this engine we need the following env variables.
LETS_ENCRYPT_PRIVATE_KEY: < For requesting SSL certificates >
LETS_ENCRYPT_DIRECTORY_URL: < For requesting SSL certificates >
LETS_ENCRYPT_APP_NAME: < For pushing SSL certificate and custom domains >
NEETO_DEPLOY_APP: < To identify in which platform the app is deployed NeetoDEploy/Heroku>
NEETO_DEPLOY_AUTH_TOKEN: <For pushing SSL certificate and custom domains>Instructions for Publishing
Consult the building and releasing packages guide for details on how to publish.
Integrations
- NeetoCal
- NeetoForm
- NeetoKb
- NeetoEngage
- NeetoSite
- NeetoRecord
- NeetoPublish
- NeetoCourse
- NeetoCode
- NeetoDesk
- NeetoQuiz
- NeetoPlanner
- NeetoInvoice
- NeetoChat
- NeetoRunner
- NeetoWireframe
