• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

inclusion-numerique / coop-mediation-numerique / a499b582-7152-4ae6-bfae-41b25ff83c10

31 Mar 2026 03:49PM UTC coverage: 7.472% (-3.2%) from 10.692%
a499b582-7152-4ae6-bfae-41b25ff83c10

Pull #466

circleci

marc-gavanier
refactor(inscription): extract ajouterLieuxActivite into modular use-case

Refactor 174 lines of mixed logic into composable, testable functions:

- domain/types.ts: Pure type definitions
- domain/classifyLieu.ts: Pure classification logic (4 cases)
- domain/filterAlreadyLinked.ts: Pure filtering logic
- dependencies/types.ts: Injectable dependency contracts
- dependencies/prisma.ts: Production implementations
- dependencies/inMemory.ts: Test implementations (no mocks)
- strategies/processClassifiedLieu.ts: Case execution
- ajouterLieuxActivite.ts: Orchestration (~40 lines)

23 unit tests with real in-memory implementations.
Fixes issue where structures from API Entreprise were not being created.
Pull Request #466: refactor(inscription): extract ajouterLieuxActivite into modular use-case

500 of 10544 branches covered (4.74%)

Branch coverage included in aggregate %.

145 of 186 new or added lines in 15 files covered. (77.96%)

1379 existing lines in 152 files now uncovered.

1500 of 16224 relevant lines covered (9.25%)

36.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/web/src/server/rpc/createRouter.ts
1
import { AppContext } from '@app/web/server/rpc/createContext'
2
import { transformer } from '@app/web/utils/serialization'
3
import { initTRPC, TRPCError } from '@trpc/server'
4

UNCOV
5
const t = initTRPC.context<AppContext>().create({
×
6
  transformer,
7
  errorFormatter({ shape }) {
8
    return shape
×
9
  },
10
})
11

UNCOV
12
export const { router } = t
×
UNCOV
13
const { procedure, middleware } = t
×
14
/**
15
 * Unprotected procedure
16
 * */
UNCOV
17
export const publicProcedure = procedure
×
18

19
/**
20
 * Reusable middleware to ensure
21
 * users are logged in
22
 */
UNCOV
23
const isAuthenticated = middleware(({ ctx, next }) => {
×
24
  if (!ctx.user) {
×
25
    throw new TRPCError({
×
26
      code: 'UNAUTHORIZED',
27
      message: 'Not authenticated',
28
    })
29
  }
30
  return next({
×
31
    ctx: {
32
      // infers the user as non-nullable
33
      user: ctx.user,
34
    },
35
  })
36
})
37
/**
38
 * Reusable middleware to ensure
39
 * users are active
40
 */
UNCOV
41
const isActive = middleware(({ ctx, next }) => {
×
42
  const { user, sessionToken } = ctx
×
43

44
  if (!user || !user.emailVerified || !sessionToken) {
×
45
    throw new TRPCError({
×
46
      code: 'UNAUTHORIZED',
47
      message: 'User status non active',
48
    })
49
  }
50
  return next({
×
51
    ctx: {
52
      ...ctx,
53
      // Infer the user as non nullable in next execution
54
      user,
55
      sessionToken,
56
    },
57
  })
58
})
59

60
/**
61
 * Protected procedure
62
 * */
UNCOV
63
export const protectedProcedure = procedure.use(isAuthenticated).use(isActive)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc