View cli.test.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async handler(argv, {console, describe, options, style}) { | |
// Print command description | |
console.important(describe); | |
// Prompt user for option or use default | |
const value = await console.cli.require(options.val); | |
// Print 'value' with style and color | |
console.log('value:', style.bold.cyan(value), style.gray(argv.val)); | |
} |
View cli.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {createCommand} from '@mail-core/cli'; | |
export const test = createCommand({ | |
name: 'test', | |
describe: 'Тестовая команда', | |
options: { | |
val: { | |
desc: 'Any value', | |
type: 'string', |
View global.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const noop = () => {}; | |
export const nativeGlobalThis = (0 | |
|| typeof globalThis === 'object' && globalThis | |
|| typeof window === 'object' && window | |
|| typeof global === 'object' && global | |
|| {} | |
) as Window; | |
export const globalLocation = nativeGlobalThis.location || { |
View mani.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/gothing/draft" | |
"github.com/gothing/draft-demo/auth" | |
) |
View scheme.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// InitEndpointScheme - инициализация описания «конца» | |
func (a *AuthLogin) InitEndpointScheme(s *draft.Scheme) { | |
// Проект, которому принадлежит «конец» | |
s.Project("auth") | |
// Метод доступен всем | |
s.Access(draft.Access.All) | |
// Базовый метод для всех кейсов | |
s.Method(draft.Method.POST) |
View super.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AuthLoginResponse — ответ на запрос | |
type AuthLoginResponse struct { | |
// инлайн комментарий с наследованием родительского | |
UserID types.UserID `comment:"{super}, авторизованного пользователя"` | |
} |
View login.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package types | |
type Login string | |
func (v Login) TypeDescription() string { | |
return "Login пользователя (он же email, телефон или соц. аккаунт)" | |
} | |
func GenLogin() Login { | |
return "fast.test@mail.ru" |
View composeObjects-v2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Key = string; | |
type Val = string | number; | |
type KeyValue< | |
K extends Key, | |
P extends Key, // Дополнительные поля (!) | |
V extends Val, | |
> = ( | |
& Record<K, V> | |
& Record<P, any> | |
); |
View composeObjects-v1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Key = string; | |
type Val = string | number; | |
type KeyValue<K extends Key, V extends Val> = { | |
[X in K]: V; | |
} | |
type CompostedObject<KEY extends Key, T extends KeyValue<KEY, Val>[]> = | |
FlattenObject< | |
ToIntersect< | |
{ | |
[K in keyof T]: T[K] extends KeyValue<KEY, Val> |
View createTokensDict.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Primitive = string | number | boolean | null; | |
type Token<N extends string, V extends Primitive> = { | |
name: N; | |
value: V; | |
} | |
type TokensDict<T extends Token<any, any>[]> = | |
FlattenObject< | |
ToIntersect< |
NewerOlder