This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
generated from kuubson/react-vite-trpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
929 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,60 @@ | ||
module.exports = { | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const path = require('path') | ||
|
||
/** @type {import("eslint").Linter.Config} */ | ||
const config = { | ||
overrides: [ | ||
{ | ||
extends: [ | ||
'plugin:@typescript-eslint/stylistic-type-checked', | ||
'plugin:@typescript-eslint/recommended-type-checked', | ||
], | ||
files: ['*.ts', '*.tsx'], | ||
parserOptions: { | ||
project: path.join(__dirname, 'tsconfig.json'), | ||
}, | ||
}, | ||
], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'prettier', 'unused-imports'], | ||
ignorePatterns: ['node_modules', '.turbo', 'dist', 'dev-dist', 'coverage'], | ||
parserOptions: { | ||
project: path.join(__dirname, 'tsconfig.json'), | ||
}, | ||
plugins: ['@typescript-eslint', 'eslint-plugin-local-rules'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/stylistic', | ||
'plugin:@typescript-eslint/recommended', | ||
'next/core-web-vitals', | ||
'prettier', | ||
], | ||
ignorePatterns: ['node_modules', '*.stories.*', '*.test.*'], | ||
rules: { | ||
'prettier/prettier': ['error', { endOfLine: 'auto' }], | ||
'no-return-await': ['error'], | ||
'prefer-destructuring': ['error'], | ||
'object-shorthand': ['error'], | ||
'no-unneeded-ternary': ['error'], | ||
'prefer-template': ['error'], | ||
'@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }], | ||
'no-empty': ['error', { allowEmptyCatch: true }], | ||
'unused-imports/no-unused-imports': 'warn', | ||
'@next/next/no-img-element': 'off', | ||
'import/no-anonymous-default-export': 'off', | ||
'@typescript-eslint/consistent-type-definitions': ['error', 'type'], | ||
'no-process-env': 'error', | ||
'no-console': 'error', | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'warn', | ||
{ | ||
prefer: 'type-imports', | ||
fixStyle: 'inline-type-imports', | ||
}, | ||
], | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
'warn', | ||
{ | ||
argsIgnorePattern: '^_', | ||
varsIgnorePattern: '^_', | ||
}, | ||
], | ||
'object-curly-newline': [ | ||
'warn', | ||
'@typescript-eslint/no-misused-promises': [ | ||
'error', | ||
{ | ||
ObjectExpression: { | ||
multiline: true, | ||
minProperties: 2, | ||
}, | ||
checksVoidReturn: false, | ||
}, | ||
], | ||
'no-unreachable': 'error', | ||
'local-rules/require-data-mapper': 'error', | ||
}, | ||
} | ||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createClient } from '@libsql/client' | ||
import { drizzle } from 'drizzle-orm/libsql' | ||
|
||
import 'dotenv/config' | ||
|
||
const turso = createClient({ | ||
url: process.env.TURSO_CONNECTION_URL!, | ||
authToken: process.env.TURSO_AUTH_TOKEN!, | ||
}) | ||
|
||
export const db = drizzle(turso) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createInsertSchema } from 'drizzle-zod' | ||
import { z } from 'zod' | ||
|
||
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core' | ||
|
||
export const projects = sqliteTable('projects', { | ||
id: integer('id').primaryKey(), | ||
name: text('name').notNull(), | ||
}) | ||
|
||
export type InsertProject = typeof projects.$inferInsert | ||
export type SelectProjects = typeof projects.$inferSelect | ||
export const apiProject = createInsertSchema(projects, { name: z.string() }) | ||
export const apiCreateProject = apiProject.omit({ id: true }) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { db } from 'db/db' | ||
import { apiCreateProject, projects } from 'db/schema' | ||
|
||
import { publicProcedure, router } from 'trpc' | ||
|
||
export const projectsRouter = router({ | ||
create: publicProcedure.input(apiCreateProject).mutation(async req => { | ||
return await db.insert(projects).values(req.input).returning() | ||
}), | ||
|
||
getAll: publicProcedure.query(async () => { | ||
return await db.select(projects) | ||
}), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { trpc } from 'trpc' | ||
|
||
export const Home = () => { | ||
const { data } = trpc.getRole.useQuery() | ||
const { data } = trpc.project.getAll.useQuery() | ||
|
||
return <div>Current role: {data?.role}</div> | ||
return <div>All projects:</div> | ||
} |
Oops, something went wrong.