What's the proper way to access database/api?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 175
- Forks
- 17
- Avg merge
- 5h 26m
- Merged PRs (30d)
- 5
Description
Let's say I want to fetch products from the database.
that's the old way:
import express from "express";
import markoPlugin from "@marko/express";
import template from "./template.marko";
const app = express();
app.use(markoPlugin()); // Enables `res.marko(template, input)`
app.get("/", function (req, res) {
const products = req.db.find(...)
res.marko(template, {
products
});
});
app.listen(8080);
What's the proper way to do the same in marko/run?
I tried something like this in +handler.js
export const GET: MarkoRun.Handler = ({ request, platform }, next) => {
platform.response.locals = {
data: Math.random()
}
next()
};
and then in +page.marko
<h1>${$global.platform.response.locals.data}</h1>
but i'm not sure it's the best way.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the +handler.js example and the +page.marko access shown in the issue, then trace Marko Run's request and data-loading entry points. Done means identifying and documenting the supported way to fetch database or API data for a page, including how the handler's result is consumed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, typescript
- Domain
- api, backend, database
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100