-
Notifications
You must be signed in to change notification settings - Fork 15
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
24 changed files
with
237 additions
and
211 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
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,65 @@ | ||
/// context type ---- | ||
// | ||
|
||
import { LesanContenxt } from "./types.ts"; | ||
|
||
/** | ||
* variable of context | ||
* @defaultValue | ||
* the value of context is '{}' | ||
*/ | ||
let context: LesanContenxt = { | ||
Headers: new Headers(), | ||
}; | ||
|
||
/** | ||
* @returns The contextObj | ||
*/ | ||
const getContextModel = () => context; | ||
|
||
/** | ||
* @returns The contextObj | ||
*/ | ||
const setContext = ( | ||
obj: Record<string, any>, | ||
) => (context = { ...getContextModel(), ...obj }); | ||
/** | ||
* asigne all of value that we want to carry | ||
* @param con - objects of key , value | ||
* @returns nothing | ||
*/ | ||
const addContexts = (con: LesanContenxt) => context = con; | ||
|
||
/** | ||
* add values to previous values that we want to carry | ||
* @param con - objects of key , value | ||
* @returns nothing | ||
*/ | ||
const addContext = (con: LesanContenxt) => context = { ...context, con }; | ||
/** | ||
* add Request to Context because the requeste may be required in later functions | ||
* @param con - request of user | ||
* @returns nothing | ||
*/ | ||
const addReqToContext = (con: Request) => context["Request"] = con; | ||
|
||
/** | ||
* add Request Header to Context because the requeste may be required in later functions | ||
* @param con - Headers of user | ||
* @returns nothing | ||
*/ | ||
const addHeaderToContext = (con: Headers) => context["Headers"] = con; | ||
|
||
/** | ||
* this function is create for define all things in local scope | ||
* and also all functions of context define in this function | ||
* @returns - return objects of all functions that define in this function | ||
*/ | ||
export const contextFns = { | ||
getContextModel, | ||
setContext, | ||
addContexts, | ||
addContext, | ||
addReqToContext, | ||
addHeaderToContext, | ||
}; |
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
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
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
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
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
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
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
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
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,16 @@ | ||
/** | ||
* Context Holds values and carries them in functions. | ||
* @example | ||
* { | ||
* Request: "values of Req", | ||
* user: { | ||
* "_id":1, | ||
* "name":"ali", | ||
* "lastName":"Alavi" | ||
* "role":"Admin" | ||
* } * | ||
*/ | ||
export interface LesanContenxt { | ||
[key: string]: any; | ||
Headers: Headers; | ||
} |
Oops, something went wrong.