kopia lustrzana https://github.com/cloudflare/wildebeest
add prelint script
rodzic
8ee894e5ed
commit
abb6ff4b0d
|
@ -270,7 +270,8 @@ function getContentRewriter() {
|
|||
contentRewriter.on('*', {
|
||||
element(el) {
|
||||
if (!['p', 'span', 'br', 'a'].includes(el.tagName)) {
|
||||
el.tagName = 'p'
|
||||
const element = el as { tagName: string }
|
||||
element.tagName = 'p'
|
||||
}
|
||||
|
||||
if (el.hasAttribute('class')) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import type { Env } from 'wildebeest/backend/src/types/env'
|
|||
|
||||
function sqliteToPsql(query: string): string {
|
||||
let c = 0
|
||||
return query.replaceAll(/\?([0-9])?/g, (match: string, p1: string) => {
|
||||
return query.replace(/\?([0-9])?/g, (match: string, p1: string) => {
|
||||
c += 1
|
||||
return `$${p1 || c}`
|
||||
})
|
||||
|
|
|
@ -281,11 +281,12 @@ export function parseRequest(request: Request, options?: Options): ParsedSignatu
|
|||
|
||||
if (h === 'request-line') {
|
||||
if (!options.strict) {
|
||||
const cf = (request as { cf?: IncomingRequestCfProperties }).cf
|
||||
/*
|
||||
* We allow headers from the older spec drafts if strict parsing isn't
|
||||
* specified in options.
|
||||
*/
|
||||
parsed.signingString += request.method + ' ' + request.url + ' ' + request.cf?.httpProtocol
|
||||
parsed.signingString += request.method + ' ' + request.url + ' ' + cf?.httpProtocol
|
||||
} else {
|
||||
/* Strict parsing doesn't allow older draft headers. */
|
||||
throw new StrictParsingError('request-line is not a valid header ' + 'with strict parsing enabled.')
|
||||
|
|
|
@ -19,7 +19,8 @@ export function initSentry(request: Request, env: Env, context: any) {
|
|||
request,
|
||||
transportOptions: { headers },
|
||||
})
|
||||
const colo = request.cf && request.cf.colo ? request.cf.colo : 'UNKNOWN'
|
||||
const cf = (request as { cf?: IncomingRequestCfProperties }).cf
|
||||
const colo = cf?.colo ? cf.colo : 'UNKNOWN'
|
||||
sentry.setTag('colo', colo)
|
||||
|
||||
// cf-connecting-ip should always be present, but if not we can fallback to XFF.
|
||||
|
|
|
@ -26,12 +26,12 @@ export function arrayBufferToBase64(buffer: ArrayBuffer): string {
|
|||
}
|
||||
|
||||
export function b64ToUrlEncoded(str: string): string {
|
||||
return str.replaceAll(/\+/g, '-').replaceAll(/\//g, '_').replace(/=+/g, '')
|
||||
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+/g, '')
|
||||
}
|
||||
|
||||
export function urlEncodedToB64(str: string): string {
|
||||
const padding = '='.repeat((4 - (str.length % 4)) % 4)
|
||||
return str.replaceAll(/-/g, '+').replaceAll(/_/g, '/') + padding
|
||||
return str.replace(/-/g, '+').replace(/_/g, '/') + padding
|
||||
}
|
||||
|
||||
export function stringToU8Array(str: string): Uint8Array {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { cloudflarePagesAdaptor } from '@builder.io/qwik-city/adaptors/cloudflare-pages/vite'
|
||||
import { cloudflarePagesAdapter } from '@builder.io/qwik-city/adapters/cloudflare-pages/vite'
|
||||
import { extendConfig } from '@builder.io/qwik-city/vite'
|
||||
import baseConfig from '../../vite.config'
|
||||
|
||||
|
@ -11,7 +11,7 @@ export default extendConfig(baseConfig, () => {
|
|||
},
|
||||
},
|
||||
plugins: [
|
||||
cloudflarePagesAdaptor({
|
||||
cloudflarePagesAdapter({
|
||||
// Do not SSG as the D1 database is not available at build time, I think.
|
||||
// staticGenerate: true,
|
||||
}),
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"prelint": "tsc",
|
||||
"lint": "eslint src mock-db adaptors",
|
||||
"build": "vite build && vite build -c adaptors/cloudflare-pages/vite.config.ts",
|
||||
"dev": "vite --mode ssr",
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { RequestContext } from '@builder.io/qwik-city/middleware/request-handler'
|
||||
import * as access from 'wildebeest/backend/src/access'
|
||||
|
||||
type Env = {
|
||||
|
@ -6,7 +5,7 @@ type Env = {
|
|||
ACCESS_AUD: string
|
||||
}
|
||||
|
||||
export const checkAuth = async (request: RequestContext, platform: Env) => {
|
||||
export const checkAuth = async (request: Request, platform: Env) => {
|
||||
const jwt = request.headers.get('Cf-Access-Jwt-Assertion') || ''
|
||||
if (!jwt) return false
|
||||
|
||||
|
|
|
@ -59,12 +59,12 @@ export async function handleRequest(
|
|||
|
||||
if (formData.has('display_name')) {
|
||||
const value = formData.get('display_name')!
|
||||
await updateActorProperty(db, connectedActor.id, 'name', value)
|
||||
await updateActorProperty(db, connectedActor.id, 'name', value as string)
|
||||
}
|
||||
|
||||
if (formData.has('note')) {
|
||||
const value = formData.get('note')!
|
||||
await updateActorProperty(db, connectedActor.id, 'summary', value)
|
||||
await updateActorProperty(db, connectedActor.id, 'summary', value as string)
|
||||
}
|
||||
|
||||
if (formData.has('avatar')) {
|
||||
|
|
|
@ -42,11 +42,11 @@ export async function handlePostRequest(
|
|||
const properties: Record<string, string> = {}
|
||||
|
||||
if (formData.has('username')) {
|
||||
properties.preferredUsername = formData.get('username') || ''
|
||||
properties.preferredUsername = (formData.get('username') as string) || ''
|
||||
}
|
||||
|
||||
if (formData.has('name')) {
|
||||
properties.name = formData.get('name') || ''
|
||||
properties.name = (formData.get('name') as string) || ''
|
||||
}
|
||||
|
||||
await createPerson(domain, db, userKEK, email, properties)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
"scripts": {
|
||||
"pretty": "npx prettier --list-different './**/*.ts'",
|
||||
"test": "NODE_OPTIONS=--experimental-vm-modules yarn jest",
|
||||
"prelint": "tsc",
|
||||
"lint": "run-s lint:* --print-label",
|
||||
"lint:frontend": "npm --prefix frontend run lint",
|
||||
"lint:backend": "npx eslint backend",
|
||||
|
|
Ładowanie…
Reference in New Issue