Commit d050514 1 parent baac022 commit d050514 Copy full SHA for d050514
File tree 3 files changed +35
-27
lines changed
3 files changed +35
-27
lines changed Original file line number Diff line number Diff line change 1
1
import './handler'
2
+ import './middlewares/auth'
2
3
import './services/users'
3
4
import './services/mails'
4
- import './wizard'
5
+ import { wizard } from './wizard'
5
6
6
- // import fs from 'node:fs'
7
- // import { logger } from '../src/internal/logger'
8
- // import { wizard } from './wizard'
9
-
10
- // const result = await wizard.api.call(
11
- // 'users@0.1.1#create',
12
- // {
13
- // name: 'alice',
14
- // },
15
- // {
16
- // stream: [fs.createReadStream('.env'), fs.createReadStream('tsconfig.json')],
17
- // }
18
- // )
19
-
20
- // logger.log(result)
7
+ const result = await wizard . api . call ( 'users@0.1.1#signOut' , { } , { } )
Original file line number Diff line number Diff line change
1
+ import { wizard } from '../wizard'
2
+
3
+ export const auth = wizard . api . createMiddleware (
4
+ {
5
+ name : 'auth' ,
6
+ share : [ 'token' ] ,
7
+ } ,
8
+ ( ctx , next ) => {
9
+ ctx . share . token = 'qwerty1234567890'
10
+ return next
11
+ }
12
+ )
13
+
14
+ declare global {
15
+ // biome-ignore lint/style/noNamespace: <explanatiion>
16
+ namespace Sirutils {
17
+ // biome-ignore lint/style/noNamespace: <explanatiion>
18
+ namespace Wizard {
19
+ interface ContextShare {
20
+ token : string
21
+ }
22
+ }
23
+
24
+ interface WizardMiddlewares {
25
+ auth : typeof auth
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change @@ -6,20 +6,13 @@ const usersService = await wizard.api.service({
6
6
description : 'users api' ,
7
7
8
8
actions : {
9
- create : wizard . api . createAction (
9
+ signOut : wizard . api . createAction (
10
10
{
11
- body : {
12
- name : 'string' ,
13
- } ,
14
- rest : true ,
15
- stream : true ,
16
- multipart : true ,
11
+ middlewares : [ 'auth' ] ,
17
12
} ,
18
13
ctx => {
19
- if ( ctx . streams ) {
20
- // biome-ignore lint/suspicious/noConsole: <explanation>
21
- console . log ( ctx . streams )
22
- }
14
+ // biome-ignore lint/suspicious/noConsole: <explanation>
15
+ console . log ( ctx . share ?. token )
23
16
24
17
return 'sa' as const
25
18
}
You can’t perform that action at this time.
0 commit comments