Skip to content

Commit 9ee75dc

Browse files
Add Prisma import alias to package.json
1 parent f5102cf commit 9ee75dc

File tree

14 files changed

+73
-83
lines changed

14 files changed

+73
-83
lines changed

app/routes/users/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { searchUsers } from '../../../prisma/generated/sql'
1+
import { searchUsers } from '#prisma/generated/sql.ts'
22
import { Img } from 'openimg/react'
33
import { redirect, Link } from 'react-router'
44
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'

app/utils/auth.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import crypto from 'node:crypto'
2-
import { type Connection, type Password, type User } from '../../prisma/generated/client'
2+
import {
3+
type Connection,
4+
type Password,
5+
type User,
6+
} from '#prisma/generated/client.ts'
37
import bcrypt from 'bcryptjs'
48
import { redirect } from 'react-router'
59
import { Authenticator } from 'remix-auth'

app/utils/db.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'dotenv/config'
22
import { styleText } from 'node:util'
33
import { remember } from '@epic-web/remember'
4-
import { PrismaClient } from '../../prisma/generated/client'
5-
import { PrismaBetterSQLite3 } from "@prisma/adapter-better-sqlite3"
4+
import { PrismaClient } from '#prisma/generated/client.ts'
5+
import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3'
66

77
export const prisma = remember('prisma', () => {
88
// NOTE: if you change anything in this function you'll need to restart

docs/database.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ You've got a few options:
300300
re-generating the migration after fixing the error.
301301
3. If you do care about the data and don't have a backup, you can follow these
302302
steps:
303-
304303
1. Comment out the
305304
[`exec` section from `litefs.yml` file](https://github.com/epicweb-dev/epic-stack/blob/main/other/litefs.yml#L31-L37).
306305

docs/decisions/031-imports.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ and manually modify.
2828
Despite the magic of Path aliases, they are actually a standard `package.json`
2929
supported feature. Sort of.
3030
[The `"imports"` field](https://nodejs.org/api/packages.html#imports) in
31-
`package.json` allows you to configure aliases for your imports.
32-
TypeScript also uses this for its own Path aliases since version 5.4
33-
so you get autocomplete and type checking for your imports.
31+
`package.json` allows you to configure aliases for your imports. TypeScript also
32+
uses this for its own Path aliases since version 5.4 so you get autocomplete and
33+
type checking for your imports.
3434

3535
By using the `"imports"` field, you don't have to do any special configuration
3636
for `vitest` or `eslint` to be able to resolve imports. They just resolve them
@@ -44,7 +44,8 @@ again it's just a matter of familiarity. So it's no big deal.
4444

4545
## Decision
4646

47-
We're going to configure `"imports"` in the `package.json` to use path aliases for imports.
47+
We're going to configure `"imports"` in the `package.json` to use path aliases
48+
for imports.
4849

4950
We'll set it to `"#*": "./*"` which will allow us to import anything in the root
5051
of the repo with `#<dirname>/<filepath>`.

docs/decisions/039-passkeys.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ username/password and OAuth providers. While these methods are widely used, they
1111
come with various security challenges:
1212

1313
1. Password-based authentication:
14-
1514
- Users often reuse passwords across services
1615
- Passwords can be phished or stolen
1716
- Password management is a burden for users
@@ -39,14 +38,12 @@ using:
3938
The authentication flow works as follows:
4039

4140
1. Registration:
42-
4341
- Server generates a challenge and sends registration options
4442
- Client creates a new key pair and signs the challenge with the private key
4543
- Public key and metadata are sent to the server for storage
4644
- Private key remains securely stored in the authenticator
4745

4846
2. Authentication:
49-
5047
- Server generates a new challenge
5148
- Client signs it with the stored private key
5249
- Server verifies the signature using the stored public key
@@ -64,19 +61,16 @@ While passkeys represent the future of authentication, we maintain support for
6461
password and OAuth authentication because:
6562

6663
1. Adoption and Transition:
67-
6864
- Passkey support is still rolling out across platforms and browsers
6965
- Users need time to become comfortable with the new technology
7066
- Organizations may have existing requirements for specific auth methods
7167

7268
2. Fallback Options:
73-
7469
- Some users may not have compatible devices
7570
- Enterprise environments might restrict biometric authentication
7671
- Backup authentication methods provide reliability
7772

7873
3. User Choice:
79-
8074
- Different users have different security/convenience preferences
8175
- Some scenarios may require specific authentication types
8276
- Supporting multiple methods maximizes accessibility
@@ -112,43 +106,37 @@ We chose SimpleWebAuthn because:
112106
### Positive:
113107

114108
1. Enhanced Security for Users:
115-
116109
- Phishing-resistant authentication adds protection against common attacks
117110
- Hardware-backed security provides stronger guarantees than passwords alone
118111
- Biometric authentication reduces risk of credential sharing
119112

120113
2. Improved User Experience Options:
121-
122114
- Users can choose between password, OAuth, or passkey based on their needs
123115
- Native biometric flows provide fast and familiar authentication
124116
- Password manager integration enables seamless cross-device access
125117
- Multiple authentication methods increase accessibility
126118

127119
3. Future-Proofing Authentication:
128-
129120
- Adoption of web standard
130121
- Gradual transition path as passkey support grows
131122
- Meeting evolving security best practices
132123

133124
### Negative:
134125

135126
1. Implementation Complexity:
136-
137127
- WebAuthn is a complex specification
138128
- Need to handle various device capabilities
139129
- Must maintain backward compatibility
140130
- Need to maintain password-based auth as fallback
141131

142132
2. User Education:
143-
144133
- New technology requires user education
145134
- Some users may be hesitant to adopt
146135
- Need clear documentation and UI guidance
147136

148137
### Neutral:
149138

150139
1. Data Storage:
151-
152140
- New database model for passkeys
153141
- Additional storage requirements per user
154142
- Migration path for existing users

docs/decisions/043-pwnedpasswords.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,19 @@ However, we wanted to implement this in a way that:
2222
We will integrate the HaveIBeenPwned Password API with the following approach:
2323

2424
1. **Progressive Enhancement**
25-
2625
- The password check is implemented as a non-blocking enhancement
2726
- If the check fails or times out (>1s), we allow the password
2827
- This ensures users can still set passwords even if the service is
2928
unavailable
3029

3130
2. **Development Experience**
32-
3331
- The API calls are mocked during development and testing using MSW (Mock
3432
Service Worker)
3533
- This prevents unnecessary API calls during development
3634
- Allows for consistent testing behavior
3735
- Follows our pattern of mocking external services
3836

3937
3. **Error Handling**
40-
4138
- Timeout after 1 second to prevent blocking users
4239
- Graceful fallback if the service is unavailable
4340
- Warning logs for monitoring service health

docs/decisions/044-rr-devtools.md

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,33 @@ Status: accepted
66

77
## Context
88

9-
Epic Stack uses React Router for routing. React Router is a powerful
10-
library, but it can be difficult to debug and visualize the routing
11-
in your application. This is especially true when you have a complex
12-
routing structure with nested routes, dynamic routes, and you rely
13-
on data functions like loaders and actions, which the Epic Stack does.
14-
15-
It is also hard to know which routes are currently active
16-
(which ones are rendered) and if any if the loaders are triggered
17-
when you expect them to be. This can lead to confusion and frustration
18-
and the use of console.log statements to debug the routing in your
19-
application.
20-
21-
This is where the React Router DevTools come in. The React
22-
Router DevTools are a set of tools that do all of these things for you.
23-
24-
React Router has a set of DevTools that help debug and visualize the
25-
routing in your application. The DevTools allow you to see the
26-
current route information, including the current location, the matched
27-
routes, and the route hierarchy. This can be very helpful when debugging
28-
your applications. The DevTools also hook into your server-side by
29-
wrapping loaders and actions, allowing you to get extensive
30-
information about the data being loaded and the actions being dispatched.
9+
Epic Stack uses React Router for routing. React Router is a powerful library,
10+
but it can be difficult to debug and visualize the routing in your application.
11+
This is especially true when you have a complex routing structure with nested
12+
routes, dynamic routes, and you rely on data functions like loaders and actions,
13+
which the Epic Stack does.
14+
15+
It is also hard to know which routes are currently active (which ones are
16+
rendered) and if any if the loaders are triggered when you expect them to be.
17+
This can lead to confusion and frustration and the use of console.log statements
18+
to debug the routing in your application.
19+
20+
This is where the React Router DevTools come in. The React Router DevTools are a
21+
set of tools that do all of these things for you.
22+
23+
React Router has a set of DevTools that help debug and visualize the routing in
24+
your application. The DevTools allow you to see the current route information,
25+
including the current location, the matched routes, and the route hierarchy.
26+
This can be very helpful when debugging your applications. The DevTools also
27+
hook into your server-side by wrapping loaders and actions, allowing you to get
28+
extensive information about the data being loaded and the actions being
29+
dispatched.
3130

3231
## Decision
3332

34-
We will add the React Router DevTools to the Epic Stack. The DevTools
35-
will be added to the project as a development dependency. The DevTools
36-
will be used in development mode only.
33+
We will add the React Router DevTools to the Epic Stack. The DevTools will be
34+
added to the project as a development dependency. The DevTools will be used in
35+
development mode only.
3736

3837
The DevTools will be used to enhance the following:
3938

@@ -45,19 +44,18 @@ The DevTools will be used to enhance the following:
4544
6. See cache information returned via headers from your loaders
4645
7. See which loaders/actions are triggered when you navigate to a route
4746
8. and a lot more!
48-
4947

5048
## Consequences
5149

5250
With the addition of the React Router DevTools, you will not have to rely on
53-
console.log statements to debug your routing. The DevTools will provide you
54-
with the tools to ship your applications faster and with more confidence.
51+
console.log statements to debug your routing. The DevTools will provide you with
52+
the tools to ship your applications faster and with more confidence.
5553

56-
The DevTools will also help you visualize the routing in your application,
57-
which can be very helpful in understanding routing in general, and figuring
58-
out if your routes are set up correctly.
54+
The DevTools will also help you visualize the routing in your application, which
55+
can be very helpful in understanding routing in general, and figuring out if
56+
your routes are set up correctly.
5957

60-
They are not included in the production build by default, so you will not
61-
have to worry about them being included in your production bundle.
62-
They are only included in development mode, so you can use them without
63-
any negative performance impact in production.
58+
They are not included in the production build by default, so you will not have
59+
to worry about them being included in your production bundle. They are only
60+
included in development mode, so you can use them without any negative
61+
performance impact in production.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"type": "module",
88
"imports": {
99
"#app/*": "./app/*",
10-
"#tests/*": "./tests/*"
10+
"#tests/*": "./tests/*",
11+
"#prisma/*": "./prisma/*"
1112
},
1213
"scripts": {
1314
"build": "run-s build:*",

prisma.config.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import "dotenv/config";
2-
import { defineConfig, env } from "prisma/config";
1+
import 'dotenv/config'
2+
import { defineConfig, env } from 'prisma/config'
33

44
export default defineConfig({
5-
schema: "prisma/schema.prisma",
6-
migrations: {
7-
path: "prisma/migrations",
8-
seed: "tsx prisma/seed.ts",
9-
},
10-
engine: "classic",
11-
datasource: {
12-
url: env("DATABASE_URL"),
13-
},
14-
});
5+
schema: 'prisma/schema.prisma',
6+
migrations: {
7+
path: 'prisma/migrations',
8+
seed: 'tsx prisma/seed.ts',
9+
},
10+
engine: 'classic',
11+
datasource: {
12+
url: env('DATABASE_URL'),
13+
},
14+
})

0 commit comments

Comments
 (0)