From 076ec515d332451b4a6b329051764da525e239b2 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Fri, 18 Jan 2019 20:33:41 +0100 Subject: [PATCH] Add packages/common --- packages/common/package.json | 4 ++++ packages/common/src/IAPIDef.ts | 36 ++++++++++++++++++++++++++++++++++ packages/common/src/IRoutes.ts | 21 ++++++++++++++++++++ packages/common/src/index.ts | 23 ++-------------------- 4 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 packages/common/package.json create mode 100644 packages/common/src/IAPIDef.ts create mode 100644 packages/common/src/IRoutes.ts diff --git a/packages/common/package.json b/packages/common/package.json new file mode 100644 index 0000000..6217616 --- /dev/null +++ b/packages/common/package.json @@ -0,0 +1,4 @@ +{ + "name": "@rondo/common", + "private": true +} diff --git a/packages/common/src/IAPIDef.ts b/packages/common/src/IAPIDef.ts new file mode 100644 index 0000000..d115a97 --- /dev/null +++ b/packages/common/src/IAPIDef.ts @@ -0,0 +1,36 @@ +export interface IAPIDef { + '/auth/register': { + 'post': { + body: { + username: string + password: string + } + } + } + '/auth/login': { + 'post': { + body: { + username: string + password: string + } + } + } + '/auth/logout': { + 'get': {} + }, + '/users/password': { + 'post': { + body: { + oldPassword: string + newPassword: string + } + } + } + '/users/profile': { + 'get': { + response: { + id: number + } + } + } +} diff --git a/packages/common/src/IRoutes.ts b/packages/common/src/IRoutes.ts new file mode 100644 index 0000000..12d2789 --- /dev/null +++ b/packages/common/src/IRoutes.ts @@ -0,0 +1,21 @@ +export type IMethod = 'get' + | 'post' + | 'put' + | 'delete' + | 'patch' + | 'head' + | 'options' + +export interface IRoutes { + // has to be any because otherwise TypeScript will start + // throwing error and interfaces without an index signature + // would not be usable + [route: string]: any +} + +export interface IRoute { + params: any + query: any + body: any + response: any +} diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 12d2789..5e7f455 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,21 +1,2 @@ -export type IMethod = 'get' - | 'post' - | 'put' - | 'delete' - | 'patch' - | 'head' - | 'options' - -export interface IRoutes { - // has to be any because otherwise TypeScript will start - // throwing error and interfaces without an index signature - // would not be usable - [route: string]: any -} - -export interface IRoute { - params: any - query: any - body: any - response: any -} +export * from './IRoutes' +export * from './IAPIDef'