Skip to content

Commit 8567113

Browse files
Merge pull request #2 from diogoazevedos/test/polish-sample
2 parents 683554e + bd13349 commit 8567113

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
- 22
1717
- 24
1818
steps:
19-
- uses: actions/checkout@v4
20-
- uses: actions/setup-node@v4
19+
- uses: actions/checkout@v5
20+
- uses: actions/setup-node@v5
2121
with:
2222
node-version: ${{ matrix.node-version }}
2323
- run: npm install

main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export function pipe<Output, C, B, A, Input>(
4646
s3: Pipe<C, B>,
4747
s4: Pipe<Output, C>
4848
): Pipe<Output, Input>;
49+
/* eslint-disable max-params */
4950
export function pipe<Output, D, C, B, A, Input>(
5051
s1: Pipe<A, Input>,
5152
s2: Pipe<B, A>,
@@ -70,6 +71,7 @@ export function pipe<Output, F, E, D, C, B, A, Input>(
7071
s6: Pipe<F, E>,
7172
s7: Pipe<Output, F>
7273
): Pipe<Output, Input>;
74+
/* eslint-enable max-params */
7375
export function pipe<Input>(
7476
init: Pipe<unknown, Input>,
7577
...steps: Array<Pipe<unknown, unknown>>
@@ -107,6 +109,7 @@ export function parallel<H, G, F, E, D, C, B, A>(
107109
s3: Pipe<F, E>,
108110
s4: Pipe<H, G>
109111
): Pipe<[B, D, F, H], A & C & E & G>;
112+
/* eslint-disable max-params */
110113
export function parallel<J, I, H, G, F, E, D, C, B, A>(
111114
s1: Pipe<B, A>,
112115
s2: Pipe<D, C>,
@@ -131,6 +134,7 @@ export function parallel<N, M, L, K, J, I, H, G, F, E, D, C, B, A>(
131134
s6: Pipe<L, K>,
132135
s7: Pipe<N, M>
133136
): Pipe<[B, D, F, H, J, L, N], A & C & E & G & I & K & M>;
137+
/* eslint-enable max-params */
134138
export function parallel<Input>(...steps: Array<Pipe<unknown, Input>>): Pipe<unknown[], Input> {
135139
return async input => Promise.all(steps.map(step => step(input)));
136140
}
@@ -153,9 +157,7 @@ type Assign<T extends unknown[]> = T extends [infer Head, ...infer Tail]
153157
* //=> {name: 'John Smith', hobby: 'Coding'}
154158
* ```
155159
*/
156-
export function assign<Output extends unknown[], Input>(
157-
step: Step<Output, Input>,
158-
): Pipe<Assign<Output>, Input> {
160+
export function assign<Output extends unknown[], Input>(step: Step<Output, Input>): Pipe<Assign<Output>, Input> {
159161
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
160162
return async input => Object.assign({}, ...(await step(input)));
161163
}

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
"typescript"
3737
],
3838
"devDependencies": {
39-
"@commitlint/cli": "^19.7.1",
40-
"@commitlint/config-conventional": "^19.7.1",
41-
"@sindresorhus/tsconfig": "^7.0.0",
42-
"@types/node": "^22.13.4",
43-
"ava": "^6.2.0",
39+
"@commitlint/cli": "^20.0.0",
40+
"@commitlint/config-conventional": "^20.0.0",
41+
"@sindresorhus/tsconfig": "^8.0.1",
42+
"@types/node": "^24.5.2",
43+
"ava": "^6.4.1",
4444
"c8": "^10.1.3",
4545
"husky": "^9.1.7",
46-
"lint-staged": "^15.4.3",
47-
"tsx": "^4.19.2",
48-
"typescript": "^5.7.3",
49-
"xo": "^0.60.0"
46+
"lint-staged": "^16.2.1",
47+
"tsx": "^4.20.6",
48+
"typescript": "^5.9.2",
49+
"xo": "^1.2.2"
5050
},
5151
"commitlint": {
5252
"extends": [

sample/user/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type Logged = {
99

1010
export function makeWithUser(userService: UserService) {
1111
return middleware(async ({claim}: Authorized) => {
12-
const user = await userService.getByUserEmail(claim.email);
12+
const user = await userService.getByEmail(claim.email);
1313

1414
return {user};
1515
});

sample/user/service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type {User} from './schema.js';
33
import type {UserRepository} from './repository.js';
44

55
export type UserService = {
6-
create(name: string, email: string): Promise<void>;
7-
getByUserEmail(email: string): Promise<User>;
6+
create(name: string, email: string): Promise<User>;
7+
getByEmail(email: string): Promise<User>;
88
};
99

1010
type UserServiceDependency = {
@@ -28,9 +28,11 @@ export function makeUserService({userRepository}: UserServiceDependency): UserSe
2828
};
2929

3030
await userRepository.create(user);
31+
32+
return user;
3133
}
3234

33-
async function getByUserEmail(email: string) {
35+
async function getByEmail(email: string) {
3436
const users = await userRepository.getAll();
3537

3638
const user = users.find(user => user.email === email);
@@ -42,5 +44,5 @@ export function makeUserService({userRepository}: UserServiceDependency): UserSe
4244
throw new Error('User not found');
4345
}
4446

45-
return {create, getByUserEmail};
47+
return {create, getByEmail};
4648
}

0 commit comments

Comments
 (0)