100 lines
No EOL
5 KiB
JSON
100 lines
No EOL
5 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "529b6825-e7a7-4928-a4fd-c5492a14fdde"
|
|
}
|
|
],
|
|
"langcode": [
|
|
{
|
|
"value": "en"
|
|
}
|
|
],
|
|
"type": [
|
|
{
|
|
"target_id": "daily_email",
|
|
"target_type": "node_type",
|
|
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
|
}
|
|
],
|
|
"revision_timestamp": [
|
|
{
|
|
"value": "2025-04-21T01:21:58+00:00"
|
|
}
|
|
],
|
|
"revision_uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"revision_log": [],
|
|
"status": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"title": [
|
|
{
|
|
"value": "Creating API endpoints with Astro\n"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2023-02-09T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-04-21T01:21:58+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2023\/02\/09\/creating-api-endpoints-with-astro",
|
|
"langcode": "en"
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>As well as <a href=\"https:\/\/www.oliverdavies.uk\/daily\/2023\/02\/08\/fetching-api-data-with-astro\">fetching API data<\/a>, you can also use Astro to generate your own API endpoints.<\/p>\n\n<p>This is an example of an endpoint that I recently created as part of a demo application:<\/p>\n\n<pre><code class=\"javascript\">\/\/ trains.json.ts\n\nimport data from \"@\/data.json\";\nimport type { APIRoute } from \"astro\";\nimport type { Train } from \"@\/types\";\n\nexport const get: APIRoute = () => {\n return {\n body: JSON.stringify(data.trains as Train[]),\n };\n};\n<\/code><\/pre>\n\n<p>The train data is imported from a JSON file, and Astro's <code>APIRoute<\/code> is responsible for setting the appropriate response headers.<\/p>\n\n<p>For server-side rendered applications, you can also have endpoints for <code>post<\/code>, <code>del<\/code> and <code>all<\/code>, though for this example, I only needed to support GET requests.<\/p>\n\n<p>This is something that I've used a db-json library for previously, but being able to do this in Astro seemed like a good fit as I can easily manage lists of stations as well as a single station from one JSON file but I can just take the static HTML that Astro generates and upload it to a static hosting solution which simplifies the hosting side of things a lot.<\/p>\n\n<p>And, as the example application that consumes the data is also written with Astro, having them both using the same solution has advantages too.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>As well as <a href=\"https:\/\/www.oliverdavies.uk\/daily\/2023\/02\/08\/fetching-api-data-with-astro\">fetching API data<\/a>, you can also use Astro to generate your own API endpoints.<\/p>\n\n<p>This is an example of an endpoint that I recently created as part of a demo application:<\/p>\n\n<pre><code class=\"javascript\">\/\/ trains.json.ts\n\nimport data from \"@\/data.json\";\nimport type { APIRoute } from \"astro\";\nimport type { Train } from \"@\/types\";\n\nexport const get: APIRoute = () => {\n return {\n body: JSON.stringify(data.trains as Train[]),\n };\n};\n<\/code><\/pre>\n\n<p>The train data is imported from a JSON file, and Astro's <code>APIRoute<\/code> is responsible for setting the appropriate response headers.<\/p>\n\n<p>For server-side rendered applications, you can also have endpoints for <code>post<\/code>, <code>del<\/code> and <code>all<\/code>, though for this example, I only needed to support GET requests.<\/p>\n\n<p>This is something that I've used a db-json library for previously, but being able to do this in Astro seemed like a good fit as I can easily manage lists of stations as well as a single station from one JSON file but I can just take the static HTML that Astro generates and upload it to a static hosting solution which simplifies the hosting side of things a lot.<\/p>\n\n<p>And, as the example application that consumes the data is also written with Astro, having them both using the same solution has advantages too.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
],
|
|
"feeds_item": [
|
|
{
|
|
"imported": "2025-04-21T01:21:58+00:00",
|
|
"guid": null,
|
|
"hash": "c6a3315ecb8173fc096250981c691fbe",
|
|
"target_type": "feeds_feed",
|
|
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
|
|
}
|
|
]
|
|
} |