Skip to content

Commit

Permalink
refactor(api): use # for absolute imports
Browse files Browse the repository at this point in the history
This way it is the same as in the front-end.

Related to #83
  • Loading branch information
JoosepAlviste committed Dec 30, 2023
1 parent 32ffe6c commit 28efdf3
Show file tree
Hide file tree
Showing 58 changed files with 150 additions and 153 deletions.
2 changes: 1 addition & 1 deletion apps/api/bin/clearDatabase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { clearDatabase } from '@/test/clearDatabase'
import { clearDatabase } from '#/test/clearDatabase'

await clearDatabase()
2 changes: 1 addition & 1 deletion apps/api/bin/kyselyCodegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url'

import { DialectManager, Generator } from 'kysely-codegen'

import { db } from '@/lib/db'
import { db } from '#/lib/db'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { graphql } from '@/generated/gql/index'
import { executeOperation } from '@/test/testUtils'
import { graphql } from '#/generated/gql/index'
import { executeOperation } from '#/test/testUtils'

describe('schema', () => {
it('returns a hello world', async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/bin/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'

import { FileMigrationProvider, Migrator } from 'kysely'

import { db } from '@/lib/db'
import { db } from '#/lib/db'

const __dirname = fileURLToPath(new URL('.', import.meta.url))
const migrator = new Migrator({
Expand Down
12 changes: 6 additions & 6 deletions apps/api/src/features/auth/__tests__/auth.schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type Selectable } from 'kysely'
import { nanoid } from 'nanoid'

import { userFactory } from '@/features/users'
import { type User } from '@/generated/db'
import { type LoginInput, type RegisterInput } from '@/generated/gql/graphql'
import { graphql } from '@/generated/gql/index'
import { db } from '@/lib/db'
import { checkErrors, executeOperation, expectErrors } from '@/test/testUtils'
import { userFactory } from '#/features/users'
import { type User } from '#/generated/db'
import { type LoginInput, type RegisterInput } from '#/generated/gql/graphql'
import { graphql } from '#/generated/gql/index'
import { db } from '#/lib/db'
import { checkErrors, executeOperation, expectErrors } from '#/test/testUtils'

import { hashPassword } from '../auth.service'

Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/features/auth/auth.schema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ZodError } from 'zod'

import { UserRef } from '@/features/users'
import { UnauthorizedError } from '@/lib/errors'
import { builder } from '@/schemaBuilder'
import { UserRef } from '#/features/users'
import { UnauthorizedError } from '#/lib/errors'
import { builder } from '#/schemaBuilder'

import * as authService from './auth.service'

Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/features/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import bcrypt from 'bcryptjs'
import jwt from 'jsonwebtoken'
import { ZodError } from 'zod'

import { config } from '@/config'
import { usersService } from '@/features/users'
import { type LoginInput, type RegisterInput } from '@/generated/gql/graphql'
import { type Context } from '@/types/context'
import { config } from '#/config'
import { usersService } from '#/features/users'
import { type LoginInput, type RegisterInput } from '#/generated/gql/graphql'
import { type Context } from '#/types/context'

import { ACCESS_TOKEN_COOKIE, REFRESH_TOKEN_COOKIE } from './constants'
import * as sessionRepository from './session.repository'
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/auth/session.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type InsertObject } from 'kysely'

import { type DB } from '@/generated/db'
import { type Context } from '@/types/context'
import { type DB } from '#/generated/db'
import { type Context } from '#/types/context'

export const findOne = ({
ctx,
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/__tests__/scopes.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import nock from 'nock'

import { config } from '@/config'
import { config } from '#/config'
import {
type TMDbSearchResponse,
type TMDbSeriesResponse,
type TMDbSeasonResponse,
} from '@/features/tmdb'
} from '#/features/tmdb'

export const mockTMDbSearchRequest = (
keyword: string,
Expand Down
14 changes: 7 additions & 7 deletions apps/api/src/features/series/__tests__/series.schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import {
tmdbEpisodeFactory,
tmdbSeasonFactory,
tmdbSeriesDetailsFactory,
} from '@/features/tmdb'
import { userFactory } from '@/features/users'
import { type User } from '@/generated/db'
import { graphql } from '@/generated/gql'
import { type SeriesUpdateStatusInput } from '@/generated/gql/graphql'
import { db } from '@/lib/db'
} from '#/features/tmdb'
import { userFactory } from '#/features/users'
import { type User } from '#/generated/db'
import { graphql } from '#/generated/gql'
import { type SeriesUpdateStatusInput } from '#/generated/gql/graphql'
import { db } from '#/lib/db'
import {
checkErrors,
createSeriesWithEpisodesAndSeasons,
executeOperation,
expectErrors,
} from '@/test/testUtils'
} from '#/test/testUtils'

import { UserSeriesStatus } from '../constants'
import { episodeFactory } from '../episode.factory'
Expand Down
10 changes: 5 additions & 5 deletions apps/api/src/features/series/__tests__/series.service.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { type LiterallyAnything } from '@serieslist/type-utils'
import { format, subDays } from 'date-fns'

import { seriesProgressFactory } from '@/features/seriesProgress'
import { seriesProgressFactory } from '#/features/seriesProgress'
import {
tmdbEpisodeFactory,
tmdbNotFoundResponseFactory,
tmdbSeasonFactory,
tmdbSeriesDetailsFactory,
} from '@/features/tmdb'
import { userFactory } from '@/features/users'
import { db } from '@/lib/db'
} from '#/features/tmdb'
import { userFactory } from '#/features/users'
import { db } from '#/lib/db'
import {
createContext,
createSeenEpisodesForUser,
createSeriesWithEpisodesAndSeasons,
} from '@/test/testUtils'
} from '#/test/testUtils'

import { episodeFactory } from '../episode.factory'
import { seasonFactory } from '../season.factory'
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/features/series/episode.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Factory } from 'fishery'
import { type Selectable } from 'kysely'
import { nanoid } from 'nanoid'

import { type Episode } from '@/generated/db'
import { db } from '@/lib/db'
import { generateRandomInt } from '@/utils/generateRandomInt'
import { type Episode } from '#/generated/db'
import { db } from '#/lib/db'
import { generateRandomInt } from '#/utils/generateRandomInt'

import { seasonFactory } from './season.factory'

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/episode.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type InsertObject } from 'kysely'

import { type DB } from '@/generated/db'
import { type DBContext, type Context } from '@/types/context'
import { type DB } from '#/generated/db'
import { type DBContext, type Context } from '#/types/context'

/**
* Return the episode TMDB IDs and season IDs ordered by the season and
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/features/series/episodes.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import index from 'just-index'
import { type Selectable } from 'kysely'

import { type Episode } from '@/generated/db'
import { type DBContext, type Context } from '@/types/context'
import { groupEntitiesByKeyToNestedArray } from '@/utils/groupEntitiesByKeyToNestedArray'
import { type Episode } from '#/generated/db'
import { type DBContext, type Context } from '#/types/context'
import { groupEntitiesByKeyToNestedArray } from '#/utils/groupEntitiesByKeyToNestedArray'

import * as episodeRepository from './episode.repository'

Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/features/series/season.factory.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Factory } from 'fishery'
import { type Selectable } from 'kysely'

import { type Season } from '@/generated/db'
import { db } from '@/lib/db'
import { generateRandomInt } from '@/utils/generateRandomInt'
import { type Season } from '#/generated/db'
import { db } from '#/lib/db'
import { generateRandomInt } from '#/utils/generateRandomInt'

import { seriesFactory } from './series.factory'

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/season.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type InsertObject } from 'kysely'

import { type DB } from '@/generated/db'
import { type DBContext, type Context } from '@/types/context'
import { type DB } from '#/generated/db'
import { type DBContext, type Context } from '#/types/context'

export const findOne = ({
ctx,
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/season.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type DBContext, type Context } from '@/types/context'
import { groupEntitiesByKeyToNestedArray } from '@/utils/groupEntitiesByKeyToNestedArray'
import { type DBContext, type Context } from '#/types/context'
import { groupEntitiesByKeyToNestedArray } from '#/utils/groupEntitiesByKeyToNestedArray'

import * as seasonRepository from './season.repository'

Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/features/series/series.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Factory } from 'fishery'
import { type Selectable } from 'kysely'
import { nanoid } from 'nanoid'

import { type Series } from '@/generated/db'
import { db } from '@/lib/db'
import { generateRandomInt } from '@/utils/generateRandomInt'
import { type Series } from '#/generated/db'
import { db } from '#/lib/db'
import { generateRandomInt } from '#/utils/generateRandomInt'

export const seriesFactory = Factory.define<Selectable<Series>>(
({ sequence, onCreate }) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/series.repository.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type UpdateObject } from 'kysely'
import { type InsertObject } from 'kysely/dist/cjs/parser/insert-values-parser'

import { type DB } from '@/generated/db'
import { type DBContext, type Context } from '@/types/context'
import { type DB } from '#/generated/db'
import { type DBContext, type Context } from '#/types/context'

import { type UserSeriesStatus } from './constants'

Expand Down
10 changes: 5 additions & 5 deletions apps/api/src/features/series/series.schema.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type Selectable } from 'kysely'
import { ZodError } from 'zod'

import { type Episode } from '@/generated/db'
import { NotFoundError, UnauthorizedError } from '@/lib/errors'
import { builder } from '@/schemaBuilder'
import { type Context } from '@/types/context'
import { exposeDate } from '@/utils/exposeDate'
import { type Episode } from '#/generated/db'
import { NotFoundError, UnauthorizedError } from '#/lib/errors'
import { builder } from '#/schemaBuilder'
import { type Context } from '#/types/context'
import { exposeDate } from '#/utils/exposeDate'

import { UserSeriesStatus } from './constants'
import * as episodesService from './episodes.service'
Expand Down
16 changes: 8 additions & 8 deletions apps/api/src/features/series/series.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import index from 'just-index'
import unique from 'just-unique'
import { type Insertable } from 'kysely'

import { seriesProgressService } from '@/features/seriesProgress'
import { tmdbService } from '@/features/tmdb'
import { type Season } from '@/generated/db'
import { seriesProgressService } from '#/features/seriesProgress'
import { tmdbService } from '#/features/tmdb'
import { type Season } from '#/generated/db'
import {
type SeriesUpdateStatusInput,
type SeriesSearchInput,
} from '@/generated/gql/graphql'
import { NotFoundError } from '@/lib/errors'
import { log } from '@/lib/logger'
} from '#/generated/gql/graphql'
import { NotFoundError } from '#/lib/errors'
import { log } from '#/lib/logger'
import {
type DBContext,
type AuthenticatedContext,
type Context,
} from '@/types/context'
import { isTruthy } from '@/utils/isTruthy'
} from '#/types/context'
import { isTruthy } from '#/utils/isTruthy'

import { UserSeriesStatus } from './constants'
import * as episodeRepository from './episode.repository'
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/seriesSync.job.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createQueue, createWorker } from '@/lib/bullMq'
import { db } from '@/lib/db'
import { createQueue, createWorker } from '#/lib/bullMq'
import { db } from '#/lib/db'

export const seriesSyncQueue = createQueue('seriesSync')

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/userSeriesStatus.factory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Factory } from 'fishery'
import { type Selectable } from 'kysely'

import { type UserSeriesStatus } from '@/generated/db'
import { db } from '@/lib/db'
import { type UserSeriesStatus } from '#/generated/db'
import { db } from '#/lib/db'

import { userFactory } from '../users'

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/features/series/userSeriesStatus.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type InsertObject } from 'kysely'

import { type DB } from '@/generated/db'
import { type Context } from '@/types/context'
import { type DB } from '#/generated/db'
import { type Context } from '#/types/context'

export const findMany = ({
ctx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import {
episodeFactory,
UserSeriesStatus,
userSeriesStatusFactory,
} from '@/features/series'
import { userFactory } from '@/features/users'
import { type User } from '@/generated/db'
import { graphql } from '@/generated/gql'
} from '#/features/series'
import { userFactory } from '#/features/users'
import { type User } from '#/generated/db'
import { graphql } from '#/generated/gql'
import {
type MarkSeriesEpisodesAsSeenInput,
type MarkSeasonEpisodesAsSeenInput,
type ToggleEpisodeSeenInput,
} from '@/generated/gql/graphql'
import { db } from '@/lib/db'
} from '#/generated/gql/graphql'
import { db } from '#/lib/db'
import {
checkErrors,
createSeenEpisodesForUser,
createSeriesWithEpisodesAndSeasons,
executeOperation,
} from '@/test/testUtils'
} from '#/test/testUtils'

import { seenEpisodeFactory } from '../seenEpisode.factory'
import { seriesProgressFactory } from '../seriesProgress.factory'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { seriesFactory } from '@/features/series'
import { db } from '@/lib/db'
import { seriesFactory } from '#/features/series'
import { db } from '#/lib/db'
import {
createContext,
createSeenEpisodesForUser,
createSeriesWithEpisodesAndSeasons,
} from '@/test/testUtils'
} from '#/test/testUtils'

import { seriesProgressFactory } from '../seriesProgress.factory'
import {
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/features/seriesProgress/seenEpisode.factory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Factory } from 'fishery'
import { type Selectable } from 'kysely'

import { episodeFactory } from '@/features/series'
import { userFactory } from '@/features/users'
import { type SeenEpisode } from '@/generated/db'
import { db } from '@/lib/db'
import { episodeFactory } from '#/features/series'
import { userFactory } from '#/features/users'
import { type SeenEpisode } from '#/generated/db'
import { db } from '#/lib/db'

export const seenEpisodeFactory = Factory.define<Selectable<SeenEpisode>>(
({ onCreate, params }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type InsertObject } from 'kysely'

import { type DB } from '@/generated/db'
import { type Context } from '@/types/context'
import { type DB } from '#/generated/db'
import { type Context } from '#/types/context'

export const findOne = ({
ctx,
Expand Down
Loading

0 comments on commit 28efdf3

Please sign in to comment.