Seamlessly integrate frontend and backend, making importing backend code on the frontend possible, convenient and secure.
import { getCurrentUser } from '../api/Actions/users.js'
getCurrentUser().then(user => {
document.getElementById('app').innerHTML = JSON.stringify(user)
})
npm install seamlessly
- Copy
.seamlessyrc.jsonto your working directory.
cp node_modules/seamlessly/.seamlesslyrc.json ./-
Choose a loader from the "loaders" folder and follow the respective README for the frontend integration.
-
Choose a backend integration from the "api-generators" folder and follow the respective README.
-
Construct an API the user can inject into his routes file to create the routes, allow an option to pass in the
rcPath(path of seamlesslyrc.json) as well as the actionsPath (path where the actions live). -
Loop through all files in the actions folder and create a POST route for each, then write the generated routes to
.seamlesslyrc.json
-
The request for each route will receive an array named
argsin its payload. Call the actual function using the spread array. -
Each route must return the following JSON format:
{
"result": "<actual result of function>"
}
{ "method": "POST", // currently always POST, subject to change "endpoint": "<file name without path and extension + function name>", "file": "<file name without path, but with extension>", "id": "<function name>" // will be used as client function name }