android + ios base
This commit is contained in:
8
web/src/server/api/root.ts
Normal file
8
web/src/server/api/root.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { exampleRouter } from "./routers/example";
|
||||
import { createTRPCRouter } from "./utils";
|
||||
|
||||
export const appRouter = createTRPCRouter({
|
||||
example: exampleRouter
|
||||
});
|
||||
|
||||
export type AppRouter = typeof appRouter;
|
||||
11
web/src/server/api/routers/example.ts
Normal file
11
web/src/server/api/routers/example.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { wrap } from "@typeschema/valibot";
|
||||
import { string } from "valibot";
|
||||
import { createTRPCRouter, publicProcedure } from "../utils";
|
||||
|
||||
export const exampleRouter = createTRPCRouter({
|
||||
hello: publicProcedure
|
||||
.input(wrap(string()))
|
||||
.query(({ input }) => {
|
||||
return `Hello ${input}!`;
|
||||
})
|
||||
});
|
||||
6
web/src/server/api/utils.ts
Normal file
6
web/src/server/api/utils.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { initTRPC } from "@trpc/server";
|
||||
|
||||
export const t = initTRPC.create();
|
||||
|
||||
export const createTRPCRouter = t.router;
|
||||
export const publicProcedure = t.procedure;
|
||||
11
web/src/server/db/index.ts
Normal file
11
web/src/server/db/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createClient } from "@libsql/client";
|
||||
import { drizzle } from "drizzle-orm/libsql";
|
||||
|
||||
import * as schema from "./schema";
|
||||
|
||||
const client = createClient({
|
||||
url: process.env.DATABASE_URL ?? "file:local.db",
|
||||
authToken: process.env.DATABASE_AUTH_TOKEN,
|
||||
});
|
||||
|
||||
export const db = drizzle(client, { schema });
|
||||
10
web/src/server/db/schema.ts
Normal file
10
web/src/server/db/schema.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const users = sqliteTable("users", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
name: text("name").notNull(),
|
||||
email: text("email").notNull().unique(),
|
||||
createdAt: integer("created_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date()),
|
||||
});
|
||||
Reference in New Issue
Block a user