0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

fix(examples): make astro check pass (#9542)

This commit is contained in:
Florian Lefebvre 2023-12-28 22:49:04 +01:00 committed by GitHub
parent 9021c18a00
commit a2977cbc5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 11 deletions

View file

@ -10,11 +10,11 @@ export default function createIntegration(): AstroIntegration {
// See the @astrojs/react integration for an example
// https://github.com/withastro/astro/blob/main/packages/integrations/react/src/index.ts
},
'astro:build:setup': ({ pages, updateConfig }) => {
'astro:build:setup': () => {
// See the @astrojs/lit integration for an example
// https://github.com/withastro/astro/blob/main/packages/integrations/lit/src/index.ts
},
'astro:build:done': ({ dir, routes }) => {
'astro:build:done': () => {
// See the @astrojs/partytown integration for an example
// https://github.com/withastro/astro/blob/main/packages/integrations/partytown/src/index.ts
},

View file

@ -15,5 +15,8 @@
"@astrojs/node": "^7.0.3",
"astro": "^4.0.8",
"html-minifier": "^4.0.0"
},
"devDependencies": {
"@types/html-minifier": "^4.0.5"
}
}

View file

@ -3,12 +3,15 @@ import htmlMinifier from 'html-minifier';
const limit = 50;
const loginInfo = {
const loginInfo: {
token: undefined | string;
currentTime: undefined | number;
} = {
token: undefined,
currentTime: undefined,
};
export const minifier = defineMiddleware(async (context, next) => {
export const minifier = defineMiddleware(async (_context, next) => {
const response = await next();
// check if the response is returning some HTML
if (response.headers.get('content-type') === 'text/html') {

View file

@ -32,7 +32,7 @@ async function get<T>(
});
if (!response.ok) {
// TODO make this better...
return null;
throw new Error('Fetch failed');
}
return cb(response);
}

View file

@ -1,4 +1,4 @@
import { APIContext } from 'astro';
import type { APIContext } from 'astro';
import { userCartItems } from '../../models/session';
export function GET({ cookies }: APIContext) {
@ -21,7 +21,7 @@ interface AddToCartItem {
export async function POST({ cookies, request }: APIContext) {
const item: AddToCartItem = await request.json();
let userId = cookies.get('user-id').value;
let userId = cookies.get('user-id')?.value;
if (!userCartItems.has(userId)) {
userCartItems.set(userId, new Map());

View file

@ -1,4 +1,4 @@
import { APIContext, APIRoute } from 'astro';
import type { APIContext, APIRoute } from 'astro';
export const POST: APIRoute = ({ cookies }: APIContext) => {
// add a new cookie

View file

@ -1,4 +1,4 @@
import { APIContext } from 'astro';
import type { APIContext } from 'astro';
export function POST({ cookies }: APIContext) {
// add a new cookie

View file

@ -13,7 +13,7 @@ export type CartItemDisplayInfo = Pick<CartItem, 'id' | 'name' | 'imageSrc'>;
export const cartItems = map<Record<string, CartItem>>({});
export function addCartItem({ id, name, imageSrc }) {
export function addCartItem({ id, name, imageSrc }: CartItem) {
const existingEntry = cartItems.get()[id];
if (existingEntry) {
cartItems.setKey(id, {

View file

@ -316,6 +316,10 @@ importers:
html-minifier:
specifier: ^4.0.0
version: 4.0.0
devDependencies:
'@types/html-minifier':
specifier: ^4.0.5
version: 4.0.5
examples/minimal:
dependencies:
@ -7372,6 +7376,13 @@ packages:
/@types/chai@4.3.11:
resolution: {integrity: sha512-qQR1dr2rGIHYlJulmr8Ioq3De0Le9E4MJ5AiaeAETJJpndT1uUNHsGFK3L/UIu+rbkQSdj8J/w2bCsBZc/Y5fQ==}
/@types/clean-css@4.2.11:
resolution: {integrity: sha512-Y8n81lQVTAfP2TOdtJJEsCoYl1AnOkqDqMvXb9/7pfgZZ7r8YrEyurrAvAoAjHOGXKRybay+5CsExqIH6liccw==}
dependencies:
'@types/node': 18.19.3
source-map: 0.6.1
dev: true
/@types/common-ancestor-path@1.0.2:
resolution: {integrity: sha512-8llyULydTb7nM9yfiW78n6id3cet+qnATPV3R44yIywxgBaa8QXFSM9QTMf4OH64QOB45BlgZ3/oL4mmFLztQw==}
dev: true
@ -7426,6 +7437,14 @@ packages:
resolution: {integrity: sha512-A8vk09eyYzk8J/lFO4OUMKCmRN0rRzfZf4n3Olwapgox/PtTiU8zPYlL1UEkJ/WeHvV6v9Xnj3o/705PKz9r4Q==}
dev: true
/@types/html-minifier@4.0.5:
resolution: {integrity: sha512-LfE7f7MFd+YUfZnlBz8W43P4NgSObWiqyKapANsWCj63Aqeqli8/9gVsGP4CwC8jPpTTYlTopKCk9rJSuht/ew==}
dependencies:
'@types/clean-css': 4.2.11
'@types/relateurl': 0.2.33
'@types/uglify-js': 3.17.4
dev: true
/@types/http-cache-semantics@4.0.4:
resolution: {integrity: sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==}
dev: true
@ -7566,6 +7585,10 @@ packages:
'@types/scheduler': 0.16.8
csstype: 3.1.3
/@types/relateurl@0.2.33:
resolution: {integrity: sha512-bTQCKsVbIdzLqZhLkF5fcJQreE4y1ro4DIyVrlDNSCJRRwHhB8Z+4zXXa8jN6eDvc2HbRsEYgbvrnGvi54EpSw==}
dev: true
/@types/resolve@1.20.6:
resolution: {integrity: sha512-A4STmOXPhMUtHH+S6ymgE2GiBSMqf4oTvcQZMcHzokuTLVYzXTB8ttjcgxOVaAp2lGwEdzZ0J+cRbbeevQj1UQ==}
dev: true
@ -7613,6 +7636,12 @@ packages:
/@types/trusted-types@2.0.7:
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
/@types/uglify-js@3.17.4:
resolution: {integrity: sha512-Hm/T0kV3ywpJyMGNbsItdivRhYNCQQf1IIsYsXnoVPES4t+FMLyDe0/K+Ea7ahWtMtSNb22ZdY7MIyoD9rqARg==}
dependencies:
source-map: 0.6.1
dev: true
/@types/ungap__structured-clone@0.3.3:
resolution: {integrity: sha512-RNmhIPwoip6K/zZOv3ypksTAqaqLEXvlNSXKyrC93xMSOAHZCR7PifW6xKZCwkbbnbM9dwB9X56PPoNTlNwEqw==}
dev: true
@ -14668,7 +14697,6 @@ packages:
/source-map@0.6.1:
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
engines: {node: '>=0.10.0'}
dev: false
/source-map@0.7.4:
resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==}