@goodrequest/flow
v0.0.1
Published
[](https://github.com/GoodRequest/flow/actions/workflows/build.yaml) [Next step is to setup middleware for hydrating storage:
app.use(flowMiddleware(Flow))Usage
When class is instantiated and data are saved using middleware, you can start using it:
const asyncData = Flow.get()Stored data
export interface AsyncStorageData<T extends Model<any, any>> {
user?: T
t: TFunction
requestID: string
request: RequestData
}
export class RequestData {
method: string
url: string
ip: string
headers: any
query: any
body: any
constructor(req: Request) {
this.method = req.method
this.url = req.originalUrl
// NOTE: x-real-ip is from nginx reverse proxy
this.ip = req.header('x-real-ip') || req.ip
this.headers = req.headers
this.query = req.query
this.body = req.body
}
}Modifications
You can implement this by yourself following this example.
