unagi7171
unagi7171
WWasp-lang
Created by unagi7171 on 11/6/2024 in #đŸ™‹questions
Is it possible to use API routers in main.wasp?
Example of a router:
import { Router } from "express";
import { UserController } from "../controllers/user.controller";
import { UserService } from "../services/user.service";
import {
registerValidator,
loginValidator,
} from "../validators/user.validator";
// import { validateRequest } from '../middleware/auth.middleware';
import { PrismaClient } from "@prisma/client";

export function createUserRouter(prisma: PrismaClient): Router {
const router = Router();
const userService = new UserService(prisma);
const userController = new UserController(userService);

router.post(
"/register",
// validateRequest,
registerValidator,
userController.register
);

router.post(
"/login",
// validateRequest,
loginValidator,
userController.login
);

return router;
}
import { Router } from "express";
import { UserController } from "../controllers/user.controller";
import { UserService } from "../services/user.service";
import {
registerValidator,
loginValidator,
} from "../validators/user.validator";
// import { validateRequest } from '../middleware/auth.middleware';
import { PrismaClient } from "@prisma/client";

export function createUserRouter(prisma: PrismaClient): Router {
const router = Router();
const userService = new UserService(prisma);
const userController = new UserController(userService);

router.post(
"/register",
// validateRequest,
registerValidator,
userController.register
);

router.post(
"/login",
// validateRequest,
loginValidator,
userController.login
);

return router;
}
Then is it possible to do this in main.wasp:
example 1:
api userRoutes {
fn: import { createUserRouter } from "@src/server/features/user/routes/user.routes",
entities: [],
httpRoute: (ANY, "/api/v1")
}

example 2:
apiNamespace loginRoutes {
fn: import { createUserRouter } from "@src/server/features/user/routes/user.routes",
entities: [],
path: "/api/v1"
}
example 1:
api userRoutes {
fn: import { createUserRouter } from "@src/server/features/user/routes/user.routes",
entities: [],
httpRoute: (ANY, "/api/v1")
}

example 2:
apiNamespace loginRoutes {
fn: import { createUserRouter } from "@src/server/features/user/routes/user.routes",
entities: [],
path: "/api/v1"
}
7 replies
WWasp-lang
Created by unagi7171 on 11/4/2024 in #đŸ™‹questions
Migration from v0.14.0 to v0.15 leads Prisma errors
Describe the bug .wasp/out/sdk/wasp/node_modules/.prisma/client/default.d.ts Is not updated to include the defined prisma schema tables. So starting the wasp server leads to getting error: Module '"@prisma/client"' has no exported member To Reproduce Steps to reproduce the behavior: Go to 'https://wasp-lang.dev/docs/migration-guides/migrate-from-0-14-to-0-15' Follow migration steps Run wasp start or npx prisma migrate .wasp/out/sdk/wasp/entities/index.ts is visibly getting errors: Module '"@prisma/client"' has no exported member "model" Expected behavior .wasp/out/sdk/wasp/entities/index.ts and .wasp/out/sdk/wasp/node_modules/.prisma/client/default.d.ts should be to have generated the defined prisma schema tables
11 replies