Skip to content

Commit

Permalink
add typecheck back in
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Dec 8, 2023
1 parent e5004cc commit cb78e1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"publishConfig": {
"access": "public"
},
"scripts": {
"typecheck": "tsc --noEmit --checkJs false --skipLibCheck"
},
"files": [
"client",
"config",
Expand Down
4 changes: 3 additions & 1 deletion packages/start/server/handler.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { renderToStream } from "solid-js/web";
/* @ts-ignore */
import { provideRequestEvent } from "solid-js/web/storage";
import {
EventHandlerObject,
EventHandlerRequest,
H3Event,
HTTPMethod,
eventHandler,
sendRedirect,
setHeader,
Expand Down Expand Up @@ -35,7 +37,7 @@ export function createHandler(

return provideRequestEvent(event, async () => {
// api
const match = matchAPIRoute(new URL(event.request.url).pathname, event.request.method)
const match = matchAPIRoute(new URL(event.request.url).pathname, event.request.method as HTTPMethod)
if (match) {
const mod = await match.handler.import();
const fn = mod[event.request.method];
Expand Down
11 changes: 6 additions & 5 deletions packages/start/shared/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fileRoutes, { RouteModule } from "vinxi/routes";
import fileRoutes from "vinxi/routes";
import { HTTPMethod } from "vinxi/server";

interface Route {
path: string;
Expand Down Expand Up @@ -27,10 +28,10 @@ declare module "vinxi/routes" {
}
}

export const pageRoutes = defineRoutes(fileRoutes.filter(o => o.type === "page"));
export const apiRoutes = defineAPIRoutes(fileRoutes.filter(o => o.type === "api"));
export const pageRoutes = defineRoutes((fileRoutes as unknown as Route[]).filter(o => o.type === "page"));
export const apiRoutes = defineAPIRoutes((fileRoutes as unknown as Route[]).filter(o => o.type === "api"));

export function matchAPIRoute(path: string, method: Method) {
export function matchAPIRoute(path: string, method: HTTPMethod) {
const segments = path.split("/").filter(Boolean);

routeLoop: for (const route of apiRoutes) {
Expand Down Expand Up @@ -72,7 +73,7 @@ export function matchAPIRoute(path: string, method: Method) {
}
}

function defineRoutes(fileRoutes: RouteModule[]) {
function defineRoutes(fileRoutes: Route[]) {
function processRoute(routes: Route[], route: Route, id: string, full: string) {
const parentRoute = Object.values(routes).find(o => {
// if (o.id.endsWith("/index")) {
Expand Down

0 comments on commit cb78e1c

Please sign in to comment.