Merge branch 'main' into main

This commit is contained in:
Chris 2023-09-05 10:13:40 +02:00 committed by GitHub
commit d0cf8c7ded
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 26 deletions

View file

@ -2,7 +2,7 @@ import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
export async function get(context) {
export async function GET(context) {
const posts = await getCollection('blog');
return rss({
title: SITE_TITLE,

View file

@ -1,11 +1,11 @@
// Returns the file body for this non-HTML file.
// The content type is based off of the extension in the filename,
// in this case: about.json.
export async function get() {
return {
body: JSON.stringify({
export async function GET() {
return new Response(
JSON.stringify({
name: 'Astro',
url: 'https://astro.build/',
}),
};
})
);
}

View file

@ -1,7 +1,7 @@
import { APIContext } from 'astro';
import { userCartItems } from '../../models/session';
export function get({ cookies }: APIContext) {
export function GET({ cookies }: APIContext) {
let userId = cookies.get('user-id').value;
if (!userId || !userCartItems.has(userId)) {
@ -12,9 +12,7 @@ export function get({ cookies }: APIContext) {
let items = userCartItems.get(userId);
let array = Array.from(items.values());
return {
body: JSON.stringify({ items: array }),
};
return new Response(JSON.stringify({ items: array }));
}
interface AddToCartItem {
@ -22,7 +20,7 @@ interface AddToCartItem {
name: string;
}
export async function post({ cookies, request }: APIContext) {
export async function POST({ cookies, request }: APIContext) {
const item: AddToCartItem = await request.json();
let userId = cookies.get('user-id').value;
@ -38,9 +36,9 @@ export async function post({ cookies, request }: APIContext) {
cart.set(item.id, { id: item.id, name: item.name, count: 1 });
}
return {
body: JSON.stringify({
return new Response(
JSON.stringify({
ok: true,
}),
};
})
);
}

View file

@ -1,7 +1,5 @@
import { products } from '../../models/db';
export function get() {
return {
body: JSON.stringify(products),
};
export function GET() {
return new Response(JSON.stringify(products));
}

View file

@ -1,14 +1,12 @@
import { productMap } from '../../../models/db';
import type { APIContext } from 'astro';
export function get({ params }: APIContext) {
export function GET({ params }: APIContext) {
const id = Number(params.id);
if (productMap.has(id)) {
const product = productMap.get(id);
return {
body: JSON.stringify(product),
};
return new Response(JSON.stringify(products));
} else {
return new Response(null, {
status: 400,

View file

@ -1779,11 +1779,11 @@ export type AstroFeatureMap = {
export interface AstroAssetsFeature {
supportKind?: SupportsKind;
/**
* Whether if this adapter deploys files in an enviroment that is compatible with the library `sharp`
* Whether if this adapter deploys files in an environment that is compatible with the library `sharp`
*/
isSharpCompatible?: boolean;
/**
* Whether if this adapter deploys files in an enviroment that is compatible with the library `squoosh`
* Whether if this adapter deploys files in an environment that is compatible with the library `squoosh`
*/
isSquooshCompatible?: boolean;
}

View file

@ -6,7 +6,7 @@
- [#8348](https://github.com/withastro/astro/pull/8348) [`5f2c55bb5`](https://github.com/withastro/astro/commit/5f2c55bb54bb66693d278b7cd705c198aecc0331) Thanks [@ematipico](https://github.com/ematipico)! - - Cache result during bundling, to speed up the process of multiple functions;
- Avoid creating multiple symbolic links of the dependencies when building the project with `funcitonPerRoute` enabled;
- Avoid creating multiple symbolic links of the dependencies when building the project with `functionPerRoute` enabled;
- [#8354](https://github.com/withastro/astro/pull/8354) [`0eb09dbab`](https://github.com/withastro/astro/commit/0eb09dbab1674a57d23ac97950a527d2e5a9c9fb) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fix unnecessary warning about Sharp showing while building