Skip to content

Instantly share code, notes, and snippets.

@john-osullivan
Last active September 16, 2019 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-osullivan/bb7f66ce60848483f6c2fd82781f0a71 to your computer and use it in GitHub Desktop.
Save john-osullivan/bb7f66ce60848483f6c2fd82781f0a71 to your computer and use it in GitHub Desktop.
Dev Diaries #2 - Example API namespace
import { XOR } from 'ts-xor';
import { ApiResponse } from '../../responses';
export namespace Login {
export const HTTP:HttpMethods.POST = 'POST';
export const Path = `${authBasePath}/${ResourcePaths.login}`
export interface Args {
username: string,
password: string
}
export function isArgs(val:any): val is Args {
return keysAreStrings(val, ['username', 'password']);
}
export function newArgs(): Args {
return {
username : '',
password : ''
}
}
export type Result = XOR<AuthData, ChallengeData>;
export type Response = ApiResponse<UserOrChallengeResult>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment