What's the proper way to access database/api?
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- express, typescript
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.
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.
- Dominant language
- TypeScript
- Stars
- 175
- Forks
- 16
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
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.
More from marko-js/run
-
DEP0190: spawnServer passes args array with shell:true, triggering Node v26 deprecation warningOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
inu-appcenter/memorIN-frontend#106 ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 7 days
-
[Bug] @deck.gl/arcgis dist import resolves to unpublished @deck.gl/core source path (9.3.11, 9.4.0)Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
CSCfi/sd-search-ui#145 ·
Maintainers usually reply within 1 day
-
Add: Cbeebies pl SDOpencheck:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day