Skip to content

Commit b9a8c52

Browse files
authored
fix types: best-practice.md (#589)
1 parent cb2eaaf commit b9a8c52

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/essential/best-practice.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ import type { AuthModel } from './model'
8787

8888
// If the class doesn't need to store a property,
8989
// you may use `abstract class` to avoid class allocation
90-
abstract class Auth {
91-
static async signIn({ username, password }: AuthModel.SignIn) {
90+
export abstract class Auth {
91+
static async signIn({ username, password }: AuthModel.signInBody) {
9292
const user = await sql`
9393
SELECT password
9494
FROM users
@@ -99,7 +99,7 @@ abstract class Auth {
9999
// You can throw an HTTP error directly
100100
throw status(
101101
400,
102-
'Invalid username or password' satisfies AuthModel.SignInInvalid
102+
'Invalid username or password' satisfies AuthModel.signInInvalid
103103
)
104104

105105
return {
@@ -122,15 +122,15 @@ export namespace AuthModel {
122122
})
123123

124124
// Define it as TypeScript type
125-
export type signInBody = typeof signIn.static
125+
export type signInBody = typeof signInBody.static
126126

127127
// Repeat for other models
128128
export const signInResponse = t.Object({
129129
username: t.String(),
130130
token: t.String(),
131131
})
132132

133-
export type signInResponse = typeof signIn.static
133+
export type signInResponse = typeof signInResponse.static
134134

135135
export const signInInvalid = t.Literal('Invalid username or password')
136136
export type signInInvalid = typeof signInInvalid.static

0 commit comments

Comments
 (0)