Last active
March 18, 2018 20:06
-
-
Save Colour-Full/6a6c8e3e2da27e1cee4dd3d3645d0b1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Then to get access to our API route we will use importer | |
var importRoutes = keystone.importer(__dirname); | |
// And finally set up the api on a route | |
var routes = { | |
api: importRoutes('./api'), | |
}; | |
// Export our app routes | |
exports = module.exports = function (app) { | |
// Get access to the API route in our app | |
app.get('/api/recipe/', keystone.middleware.api, routes.api.recipe.list); | |
// Set up the default app route to http://localhost:3000/index.html | |
app.get('/index.html', function (req, res) { | |
// Render some simple boilerplate html | |
function renderFullPage() { | |
// Note the div class name here, we will use that as a hook for our React code | |
return ` | |
<!doctype html> | |
<html> | |
<head> | |
<title>Keystone With React And Redux</title> | |
</head> | |
<body> | |
<div class="react-container"> | |
</div> | |
<script src="bundle.js"></script> | |
</body> | |
</html> | |
`; | |
} | |
// Send the html boilerplate | |
res.send(renderFullPage()); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment