Releases: lilnasy/gratelets
@emotion-extract/[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Patch Changes
- #134
1fe8f3a
Thanks @lilnasy! - The package has been updated to bring in features and improvements from@astrojs/[email protected]
.
[email protected]
Patch Changes
- #134
1fe8f3a
Thanks @lilnasy! - The package has been updated to bring in features and improvements from@astrojs/[email protected]
.
[email protected]
Patch Changes
- #134
1fe8f3a
Thanks @lilnasy! - The package has been updated to bring in features and improvements from@NuroDev/[email protected]
.
[email protected]
Minor Changes
-
#132
cf3311b
Thanks @lilnasy! - Typed API routes are now reusable throughout your project!You can define your main application logic in API routes, and then use it for server-side rendering static HTML by calling it from the frontmatter of your pages.
--- import { api } from "astro-typed-api/client" const results = await api.search.GET.fetch({ query: Astro.params.query }) --- {results.map(result => <div>{result.title}</div>)}
The
cookies
,headers
,locals
, andrequest
objects are automatically populated with the current request's values.
[email protected]
Minor Changes
-
#129
dc95fdb
Thanks @lilnasy! - Adds support for type-safe custom error handling!On the server-side, you now have access to the
error()
function in theTypedAPIContext
.// src/api/search.ts import { defineApiRoute } from "astro-typed-api/server"; export const GET = defineApiRoute({ fetch({ query }: { query: string }, { locals, error }) { if (locals.loggedInInfo) { return ["search result 1", "search result 2"]; } else { return error("login required"); } }, });
On the client-side, the error details are available inside the
.catch
handler.import { api, CustomError } from "astro-typed-api/client" const searchResults = await api.search.GET.fetch({ query: "science" }) .catch(error => { if (error instance of CustomError) { // error.reason is inferred from the server-side error() call const reason: "login required" = error.reason } })
-
#129
dc95fdb
Thanks @lilnasy! - Adds support for usingdevalue
for sending complex objects over the network.To use
devalue
instead of JSON, set theserialization
option to"devalue"
in theastro.config.js
file:// astro.config.js import { defineConfig } from "astro/config"; import typedApi from "astro-typed-api"; export default defineConfig({ integrations: [typedApi({ serialization: "devalue" })], });
[email protected]
Patch Changes
- #125
ce0b7b6
Thanks @spacedawwwg! - Fixes an issue introduced in v2.0.2 where the types for the "astro:import" would not be added to the project.