-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server-context): add new module
- Loading branch information
1 parent
cdbdce6
commit 01d843c
Showing
7 changed files
with
122 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,26 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [0.32.0](https://github.com/AliMD/alwatr/compare/v0.31.0...v0.32.0) (2023-05-27) | ||
|
||
### Bug Fixes | ||
|
||
- **context:** compatible with new storage api ([5251ff0](https://github.com/AliMD/alwatr/commit/5251ff005624720e091cdbc40e6b0142743428cb)) | ||
|
||
# [0.31.0](https://github.com/AliMD/alwatr/compare/v0.30.0...v0.31.0) (2023-05-08) | ||
|
||
### Bug Fixes | ||
|
||
- build issues ([e1060bc](https://github.com/AliMD/alwatr/commit/e1060bccbfe3c775c32b85e9b8eb601e48b2998c)) | ||
- **context:** merge request option issue ([e24e695](https://github.com/AliMD/alwatr/commit/e24e695a8c25ab1dcb1c351a3ae0434e921610d0)) | ||
- new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) | ||
- packages and refs ([eea2382](https://github.com/AliMD/alwatr/commit/eea2382e459ccaa3e7b4b329d9c196eda146a08e)) | ||
|
||
### Features | ||
|
||
- **context:** add `requestIfNotComplete` ([580d5c9](https://github.com/AliMD/alwatr/commit/580d5c9c74f1c8921b45d402641df9444f438547)) | ||
- **context:** awesome server context ([c001c58](https://github.com/AliMD/alwatr/commit/c001c58a2b1b4e13fd1c34b5128031fd640a98e1)) | ||
- **context:** new package ([98ee43d](https://github.com/AliMD/alwatr/commit/98ee43d83b1ad5b3806ec6053c5cac70912000b3)) | ||
- **context:** simple context api ([2a1b152](https://github.com/AliMD/alwatr/commit/2a1b152380f267a6b173f08bbbe10295325b1fd8)) |
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,3 @@ | ||
# Alwatr Context - `@alwatr/server-context` | ||
|
||
Elegant powerful server-context manager base on alwatr signal, written in tiny TypeScript, ES module. |
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,44 @@ | ||
{ | ||
"name": "@alwatr/server-context", | ||
"version": "0.32.0", | ||
"description": "Elegant powerful context manager base on alwatr signal, written in tiny TypeScript, ES module.", | ||
"keywords": [ | ||
"context", | ||
"server-context", | ||
"signal", | ||
"typescript", | ||
"esm", | ||
"alwatr" | ||
], | ||
"main": "index.js", | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"author": "S. Ali Mihandoost <[email protected]> (https://ali.mihandoost.com)", | ||
"license": "MIT", | ||
"files": [ | ||
"**/*.{d.ts.map,d.ts,js.map,js,html,md}" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/AliMD/alwatr", | ||
"directory": "core/server-context" | ||
}, | ||
"homepage": "https://github.com/AliMD/alwatr/tree/main/core/server-context#readme", | ||
"bugs": { | ||
"url": "https://github.com/AliMD/alwatr/issues" | ||
}, | ||
"dependencies": { | ||
"@alwatr/fetch": "^0.32.0", | ||
"@alwatr/fsm": "^0.32.0", | ||
"@alwatr/logger": "^0.32.0", | ||
"@alwatr/signal": "^0.32.0", | ||
"@alwatr/util": "^0.32.0", | ||
"tslib": "^2.5.2" | ||
}, | ||
"devDependencies": { | ||
"@alwatr/type": "^0.32.0" | ||
} | ||
} |
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 @@ | ||
export {}; |
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,28 @@ | ||
import {AlwatrBaseSignal} from '@alwatr/signal2'; | ||
import {FiniteStateMachine} from '@alwatr/fsm2'; | ||
|
||
import type { FetchOptions } from '../../fetch/src/type.js'; | ||
|
||
export interface ServerRequestConfig extends FetchOptions { | ||
name: string; | ||
} | ||
|
||
export class AlwatrServerRequest<TResponse> extends AlwatrBaseSignal<TResponse> { | ||
stateMachine = new FiniteStateMachine({ | ||
initial: '', | ||
}); | ||
|
||
constructor(protected _config: ServerRequestConfig) { | ||
super(_config.name, 'srv-request'); | ||
} | ||
|
||
request(): void ( | ||
fsm: FsmConsumerInterface<ServerContextFsm>, | ||
options?: ServerContextFsm['TContext']['options'], | ||
mergeOption = true, | ||
): void => { | ||
logger.logMethodArgs?.('request', fsm.id); | ||
if (options != null) setOptions(fsm, options, mergeOption); | ||
fsm.transition('REQUEST'); | ||
}; | ||
} |
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,19 @@ | ||
{ | ||
"extends": "../../tsconfig.base", | ||
"compilerOptions": { | ||
"composite": true, | ||
"tsBuildInfoFile": ".tsbuildinfo", | ||
"rootDir": "src", | ||
"outDir": "." | ||
}, | ||
|
||
"include": ["src/**/*.ts"], | ||
"exclude": [], | ||
"references": [ | ||
{"path": "../logger"}, | ||
{"path": "../signal2"}, | ||
{"path": "../fetch"}, | ||
{"path": "../fsm2"}, | ||
{"path": "../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