Skip to content

Commit b2ddb5e

Browse files
authored
fix(style): properly indent template, proper use of single-quotes and no trailing commas from the get-go (#8)
* fix: properly indent template, proper use of single-quotes and no trailing commas from the get-go * fix: more formatting semicolon and more fixes
1 parent 36d4acc commit b2ddb5e

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

src/steps/2.addModules/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default defineNuxtConfig(${inspect(nuxtConfig, { compact: false })})
6363
const moduleIndexHtmlSnippets = selectedModules.map((module) => moduleConfigs[module].htmlForIndexVue).filter(html => typeof html !== "undefined")
6464
const nuxtPagesIndexVue = `<template>
6565
<div>
66-
<h1${selectedModules.includes("tailwind") ? " class=\"text-4xl\"" : ""}>Welcome to your sidebase app!</h1>${moduleIndexHtmlSnippets.length > 0 ? "\n" + moduleIndexHtmlSnippets.join("\n ") : ""}
66+
<h1${selectedModules.includes("tailwind") ? " class=\"text-4xl\"" : ""}>Welcome to your sidebase app!</h1>${moduleIndexHtmlSnippets.length > 0 ? "\n " + moduleIndexHtmlSnippets.join("\n ") : ""}
6767
</div>
6868
</template>
6969
`

src/steps/2.addModules/moduleConfigs.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const prismaExampleEndpoint = `/**
3838
* return { prisma: event.context.prisma }
3939
* }
4040
*
41-
* export type Context = inferAsyncReturnType<typeof createContext>;
41+
* export type Context = inferAsyncReturnType<typeof createContext>
4242
* \`\`\`
4343
*/
4444
export default defineEventHandler(event => event.context.prisma.example.findMany())
@@ -152,8 +152,10 @@ export default NuxtAuthHandler({
152152
`
153153

154154
const nuxtAuthExamplePage = `<template>
155-
<div>I'm protected! Session data: {{ data }}</div>
156-
<button @click="signOut()" class="rounded-xl shadow-xl p-2 m-2">sign out</button>
155+
<div>
156+
<div>I'm protected! Session data: {{ data }}</div>
157+
<button class="rounded-xl shadow-xl p-2 m-2" @click="signOut()">sign out</button>
158+
</div>
157159
</template>
158160
159161
<script setup lang="ts">
@@ -176,19 +178,19 @@ const nuxtTrpcRootConfig = `/**
176178
* @see https://trpc.io/docs/v10/procedures
177179
*/
178180
import { initTRPC } from '@trpc/server'
181+
import superjson from 'superjson'
179182
import { Context } from '~/server/trpc/context'
180-
import superjson from 'superjson';
181183
182184
const t = initTRPC.context<Context>().create({
183-
transformer: superjson,
185+
transformer: superjson
184186
})
185187
186188
/**
187189
* Unprotected procedure
188190
**/
189-
export const publicProcedure = t.procedure;
190-
export const router = t.router;
191-
export const middleware = t.middleware;
191+
export const publicProcedure = t.procedure
192+
export const router = t.router
193+
export const middleware = t.middleware
192194
`
193195

194196
const nuxtTrpcRoutersIndex = `import { z } from 'zod'
@@ -198,15 +200,15 @@ export const appRouter = router({
198200
hello: publicProcedure
199201
.input(
200202
z.object({
201-
text: z.string().nullish(),
202-
}),
203+
text: z.string().nullish()
204+
})
203205
)
204206
.query(({ input }) => {
205207
return {
206-
greeting: \`hello \${input?.text ?? "world"}\`,
208+
greeting: \`hello \${input?.text ?? 'world'}\`,
207209
time: new Date()
208210
}
209-
}),
211+
})
210212
})
211213
212214
// export type definition of API
@@ -220,17 +222,17 @@ import type { H3Event } from 'h3'
220222
* Creates context for an incoming request
221223
* @link https://trpc.io/docs/context
222224
*/
223-
export async function createContext(event: H3Event) {
225+
export function createContext (_event: H3Event) {
224226
/**
225227
* Add any trpc-request context here. E.g., you could add \`prisma\` like this (if you've added it via sidebase):
226228
* \`\`\`ts
227-
* return { prisma: event.context.prisma }
229+
* return { prisma: _event.context.prisma }
228230
* \`\`\`
229231
*/
230232
return {}
231233
}
232234
233-
export type Context = inferAsyncReturnType<typeof createContext>;
235+
export type Context = inferAsyncReturnType<typeof createContext>
234236
`
235237

236238
const nuxtTrpcApiHandler = `import { createNuxtApiHandler } from 'trpc-nuxt'
@@ -240,13 +242,13 @@ import { createContext } from '~/server/trpc/context'
240242
// export API handler
241243
export default createNuxtApiHandler({
242244
router: appRouter,
243-
createContext,
245+
createContext
244246
})
245247
`
246248

247-
const nuxtTrpcPlugin = `import { createTRPCNuxtClient, httpBatchLink } from "trpc-nuxt/client"
248-
import type { AppRouter } from "~/server/trpc/routers"
249-
import superjson from 'superjson';
249+
const nuxtTrpcPlugin = `import { createTRPCNuxtClient, httpBatchLink } from 'trpc-nuxt/client'
250+
import superjson from 'superjson'
251+
import type { AppRouter } from '~/server/trpc/routers'
250252
251253
export default defineNuxtPlugin(() => {
252254
/**
@@ -257,15 +259,15 @@ export default defineNuxtPlugin(() => {
257259
transformer: superjson,
258260
links: [
259261
httpBatchLink({
260-
url: "/api/trpc",
261-
}),
262-
],
262+
url: '/api/trpc'
263+
})
264+
]
263265
})
264266
265267
return {
266268
provide: {
267-
client,
268-
},
269+
client
270+
}
269271
}
270272
})
271273
`

0 commit comments

Comments
 (0)