-
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.
Merge pull request #2 from fleetfn/types
Create the new fleetfn/types package
- Loading branch information
Showing
4 changed files
with
145 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Fleet FN, Inc | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,96 @@ | ||
export interface FleetRequest { | ||
/** | ||
* The body | ||
*/ | ||
body: any; | ||
|
||
/** | ||
* The function name that was defined in the fleet.yml manifest | ||
*/ | ||
functionName: string; | ||
|
||
/** | ||
* Uid of the function | ||
*/ | ||
functionUid: string; | ||
|
||
/** | ||
* The request headers object | ||
* - Key-value pairs of header names and values. Header names are lower-cased. | ||
*/ | ||
headers: {[k: string]: any}; | ||
|
||
/** | ||
* Hostname of the incoming request | ||
*/ | ||
hostname: string; | ||
|
||
/** | ||
* Method of the incoming request | ||
* - GET | ||
* - POST | ||
* - PUT | ||
* - PATCH | ||
* - HEAD | ||
* - OPTIONS | ||
* - DELETE | ||
*/ | ||
method: string; | ||
|
||
/** | ||
* Parsed querystring | ||
*/ | ||
query: {[k: string]: any}; | ||
|
||
/** | ||
* This contains only the URL that is present in the actual HTTP request. | ||
*/ | ||
url: string; | ||
} | ||
|
||
export interface FleetResponse { | ||
/** | ||
* Sets the status code. By default it is 200. | ||
*/ | ||
code: (code: number) => FleetResponse; | ||
|
||
/** | ||
* Retrieves the header defined before. | ||
*/ | ||
getHeader: (key: string) => string; | ||
|
||
/** | ||
* Check if a header has been set. | ||
*/ | ||
hasHeader: (key: string) => boolean; | ||
|
||
/** | ||
* Redirect to the specified URL, code is optional (Default value 302). | ||
*/ | ||
redirect: (url: string, code: number) => void; | ||
|
||
/** | ||
* Remove the value of a previously set header. | ||
*/ | ||
removeHeader: (key: string) => FleetResponse; | ||
|
||
/** | ||
* Sends the payload to the user, it can be plain text, a buffer, JSON or an Error object. | ||
*/ | ||
send: (payload?: any) => void; | ||
|
||
/** | ||
* Sets a custom serializer for the payload. | ||
*/ | ||
serializer: (fn: Function) => FleetResponse; | ||
|
||
/** | ||
* Sets a response header. | ||
*/ | ||
setHeader: (key: string, value: any) => FleetResponse; | ||
|
||
/** | ||
* Sets the header Content-Type. | ||
*/ | ||
type: (type: string) => FleetResponse; | ||
} |
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,10 @@ | ||
{ | ||
"name": "@fleetfn/types", | ||
"description": "TypeScript definitions for Fleet", | ||
"version": "1.0.0-alpha.1", | ||
"author": "Fleet FN, Inc", | ||
"main": "", | ||
"types": "index.d.ts", | ||
"license": "MIT", | ||
"typeScriptVersion": "3.2" | ||
} |
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,18 @@ | ||
{ | ||
"files": [ | ||
"index.d.ts", | ||
], | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"baseUrl": "./", | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
} | ||
} |