-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
230 additions
and
111 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
"types": "dist/index.d.ts", | ||
"repository": "https://github.com/akgurjar/express-api.git", | ||
"author": "Ashish Gurjar <[email protected]>", | ||
"license": "GNU", | ||
"license": "GPL-3.0", | ||
"private": false, | ||
"scripts": { | ||
"start": "webpack-dev-server", | ||
|
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
/** | ||
* @name parse | ||
*/ | ||
export function parse() { | ||
// TO DO | ||
return ''; | ||
} | ||
|
||
/** | ||
* @name stringify | ||
*/ | ||
export function stringify(): string { | ||
// TO DO | ||
return ''; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
|
||
export * from './lib/index'; | ||
// export * from './lib/index'; | ||
import { body } from './lib/index'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
BodyLocation, | ||
QueryLocation, | ||
ParamLocation, | ||
HeaderLocation, | ||
CookieLocation, | ||
MethodLocation, | ||
} from '../locations/index'; | ||
|
||
export function body(field: string) { | ||
return new BodyLocation(field); | ||
} | ||
export function query(field: string) { | ||
return new QueryLocation(field); | ||
} | ||
export function param(field: string) { | ||
return new ParamLocation(field); | ||
} | ||
export function header(field: string) { | ||
return new HeaderLocation(field); | ||
} | ||
export function cookie(field: string) { | ||
return new CookieLocation(field); | ||
} | ||
export function method(field: string) { | ||
return new MethodLocation(field); | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
// import { body } from './impl/index'; | ||
|
||
export * from './types/index'; | ||
export * from './locations/index'; | ||
export * from './functions/index'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { AnyType } from '../types/any.type'; | ||
import { StringType } from '../types/string.type'; | ||
import { NumberType } from '../types/number.type'; | ||
import { ArrayType } from '../types/array.type'; | ||
import { ObjectType } from '../types/object.type'; | ||
|
||
export class BaseLocation extends AnyType<any> { | ||
constructor(location: string, fieldNames: string[]) { | ||
super(); | ||
// Push field names in schema | ||
this._schema.fieldNames.splice(0, 0, ...fieldNames); | ||
// set location in schema | ||
if (location) { | ||
this._schema.locations.push(location); | ||
} | ||
} | ||
/** | ||
* @type StringType | ||
* @description StringType | ||
*/ | ||
string(): StringType { | ||
return new StringType(); | ||
} | ||
/** | ||
* @type NumberType | ||
* @description NumberType | ||
*/ | ||
number(): NumberType { | ||
return new NumberType(); | ||
} | ||
/** | ||
* @type ArrayType | ||
* @description ArrayType | ||
*/ | ||
array(): ArrayType { | ||
return new ArrayType(); | ||
} | ||
/** | ||
* @type ObjectType | ||
* @description ObjectType | ||
*/ | ||
object(): ObjectType { | ||
return new ObjectType(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/lib/schema/locations/body.location.ts → src/lib/locations/body.location.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { BaseLocation } from './base.location'; | ||
|
||
export class BodyLocation extends BaseLocation { | ||
constructor(fieldName: string) { | ||
super('body', fieldName); | ||
constructor(...fieldNames: string[]) { | ||
super('body', fieldNames); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/lib/schema/locations/cookie.location.ts → src/lib/locations/cookie.location.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { BaseLocation } from './base.location'; | ||
|
||
export class CookieLocation extends BaseLocation { | ||
constructor(fieldName: string) { | ||
super('cookie', fieldName); | ||
constructor(...fieldNames: string[]) { | ||
super('cookie', fieldNames); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/lib/schema/locations/header.location.ts → src/lib/locations/header.location.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { BaseLocation } from './base.location'; | ||
|
||
export class HeaderLocation extends BaseLocation { | ||
constructor(fieldName: string) { | ||
super('header', fieldName); | ||
constructor(...fieldNames: string[]) { | ||
super('header', fieldNames); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @name MethodLocation | ||
*/ | ||
|
||
import { BaseLocation } from './base.location'; | ||
import { BodyLocation } from './body.location'; | ||
import { QueryLocation } from './query.location'; | ||
import { ParamLocation } from './param.location'; | ||
import { HeaderLocation } from './header.location'; | ||
import { CookieLocation } from './cookie.location'; | ||
|
||
export class MethodLocation extends BaseLocation { | ||
constructor(...methods: string[]) { | ||
super(null, []); | ||
this._schema.methods.splice(0, 0, ...methods); | ||
} | ||
/** | ||
* @param fieldNames All field names | ||
*/ | ||
body(...fieldNames: string[]): BodyLocation { | ||
return new BodyLocation(...fieldNames); | ||
} | ||
/** | ||
* @param fieldNames All field names | ||
*/ | ||
query(...fieldNames: string[]): QueryLocation { | ||
return new QueryLocation(...fieldNames); | ||
} | ||
/** | ||
* @param fieldNames All field names | ||
*/ | ||
param(...fieldNames: string[]): ParamLocation { | ||
return new ParamLocation(...fieldNames); | ||
} | ||
/** | ||
* @param fieldNames All field names | ||
*/ | ||
header(...fieldNames: string[]): HeaderLocation { | ||
return new HeaderLocation(...fieldNames); | ||
} | ||
/** | ||
* @param fieldNames All field names | ||
*/ | ||
cookie(...fieldNames: string[]): CookieLocation { | ||
return new CookieLocation(...fieldNames); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/lib/schema/locations/param.location.ts → src/lib/locations/param.location.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { BaseLocation } from './base.location'; | ||
|
||
export class ParamLocation extends BaseLocation { | ||
constructor(fieldName: string) { | ||
super('param', fieldName); | ||
constructor(...fieldNames: string[]) { | ||
super('param', fieldNames); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/lib/schema/locations/query.location.ts → src/lib/locations/query.location.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { BaseLocation } from './base.location'; | ||
|
||
export class QueryLocation extends BaseLocation { | ||
constructor(fieldName: string) { | ||
super('query', fieldName); | ||
constructor(...fieldNames: string[]) { | ||
super('query', fieldNames); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
/** | ||
* @name Schema | ||
* @description A schema which can be validated, stringify, parsed easily transferred over internet. | ||
*/ | ||
|
||
export class EpiSchema { | ||
readonly methods: string[] = []; | ||
readonly locations: string[] = []; | ||
readonly fieldNames: string[] = []; | ||
readonly flags: string[] = []; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @name ArrayType | ||
* @type Array | ||
* @description ArrayType | ||
*/ | ||
|
||
import { AnyType } from './any.type'; | ||
|
||
export class ArrayType extends AnyType<string> { | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
export * from './base.type'; | ||
export * from './any.type'; | ||
export * from './string.type'; | ||
export * from './number.type'; | ||
export * from './array.type'; | ||
export * from './object.type'; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @name ObjectType | ||
* @type Object | ||
* @description ObjectType | ||
*/ | ||
|
||
import { AnyType } from './any.type'; | ||
|
||
export class ObjectType extends AnyType<string> { | ||
|
||
} |
Oops, something went wrong.