Skip to content

Commit

Permalink
refactor: drop special compatibilityVersion handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jan 7, 2025
1 parent 74353ec commit bc4938d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/utils/templates/server-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import type { Template } from '.'
import { resolve } from 'pathe'

const serverMiddleware: Template = ({ name, nuxtOptions }) => ({
path: nuxtOptions.future.compatibilityVersion === 3
? resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, 'middleware', `${name}.ts`)
: resolve(nuxtOptions.serverDir, 'middleware', `${name}.ts`),
path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, 'middleware', `${name}.ts`),
contents: `
export default defineEventHandler(event => {})
`,
Expand Down
4 changes: 1 addition & 3 deletions src/utils/templates/server-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import type { Template } from '.'
import { resolve } from 'pathe'

const serverPlugin: Template = ({ name, nuxtOptions }) => ({
path: nuxtOptions.future.compatibilityVersion === 3
? resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, 'plugins', `${name}.ts`)
: resolve(nuxtOptions.serverDir, 'plugins', `${name}.ts`),
path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, 'plugins', `${name}.ts`),
contents: `
export default defineNitroPlugin(nitroApp => {})
`,
Expand Down
4 changes: 1 addition & 3 deletions src/utils/templates/server-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import type { Template } from '.'
import { resolve } from 'pathe'

const serverRoute: Template = ({ name, args, nuxtOptions }) => ({
path: nuxtOptions.future.compatibilityVersion === 3
? resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, args.api ? 'api' : 'routes', `${name}.ts`)
: resolve(nuxtOptions.serverDir, args.api ? 'api' : 'routes', `${name}.ts`),
path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, args.api ? 'api' : 'routes', `${name}.ts`),
contents: `
export default defineEventHandler(event => {})
`,
Expand Down
4 changes: 1 addition & 3 deletions src/utils/templates/server-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { resolve } from 'pathe'
import { camelCase } from 'scule'

const serverUtil: Template = ({ name, nuxtOptions }) => ({
path: nuxtOptions.future.compatibilityVersion === 3
? resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, 'utils', `${name}.ts`)
: resolve(nuxtOptions.serverDir, 'utils', `${name}.ts`),
path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, 'utils', `${name}.ts`),
contents: `
export function ${camelCase(name)}() {}
`,
Expand Down

0 comments on commit bc4938d

Please sign in to comment.