Server side rendering using aka
Aka: You can use aka for server side rendering. It will return an ejs(Embedded Javascript) file.
Aka Template: Create a template for aka inside akaTemplates. It includes header, footer, body, styles, favicon, dataSource etc.
Aka template Model:
{
code: String,
dataSource: [{
key: String,
type: { type: String },
connectionString: String,
config: Object,
params: [{ key: String, value: String }],
field: String
}],
summary: String,
favicon: String,
title: String,
styles: String, //<style>.container{color:red}</style>
header: String, //<div>Header</div>
body: String, //<div>Body</div>
footer: String, //<div>Footer</div>
image: {
url: String,
thumbnail: String
},
from: Date,
till: Date,
status: String, // active, inactive
meta: Object
}
Code of your akaTemplate should be unique. (Required)
Your ejs file data can be constant or dynamic. For dynamic data you need to add dataSouce inside akaTemplate from where you want to get data.
Summary includes summary of your page
You can dynamically set the favicon, title, header, footer and body of your page inside the aka template. Otherwise it will pick up the default one.
You can dynamically set styles of your page.
Send aka URL inside an email:
You can attach aka URL inside an email. For attaching aka URL inside an email you need to set href inside the email template body.
Through href you can pass:
{
template: String, //akaTemplate code
query:{} //pass query for dynamically get data
}
Anything we pass inside a query is used by dataSource inside akaTemplate.
Example:
<a href='${discovery.aka.create({"template":"aka-testing-template","query":{"order":"yt-del-2122-oi-00181"}})}'>Aka template Link</a>
Inside sendIt this href is replaced by the actual aka url.
Example (Attach aka url inside email body):
Email template inside SendIt:
{
"code" : "testing-mail",
"name" : "Testing Mail Template",
"body" : "<p class=\"ql-align-center\">Dear Customer <b>{{name}}</b></p><p class=\"ql-align-center\"><b>{{subject}}</b></p><a href='${discovery.aka.create({"template":"ejs-testing-template","query":{"orderId": "yt-del-2122-oi-00181"}})}'>New aka Link</a>"
}
Aka template inside Discovery:
{
"code" : "ejs-testing-template",
"dataSource" : [
{
"key" : "order",
"type" : "http",
"connectionString" : "https://dev-api.y-dff.com/mo/api/orders/{{data.orderId}}",
"config" : {
"headers" : {
"x-tenant-code" : "{{context.tenant.code}}"
}
},
"params" : [],
"field" : "data"
}
],
"title" : "EJS Testing Template",
"favicon" : "https://www.pngitem.com/pimgs/m/114-1142068_plant-leaf-tree-tree-favicon-ico-hd-png.png",
"styles" : "<style>.container{font-size:20px;color:green}</style>",
“header”:”<div class=”container”>EJS file header</div>”,
“footer”:”<div class=”container”>EJS file footer</div>”,
“body”:”<div>EJS template body {{data.order.code}}</div>”
}
First, the request goes to sendIt.
It picks up the aka model from href and sends the request to discovery for aka
Discovery fetch the akaTemplate through template code, then take the query inject data from dataSource inside body and return aka url like:
eg: https://dev-api.y-dff.com/discovery/akas/62502f2692e8d655ebb61a88
Then this actual aka url is replaced with href inside the email body.