-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Changes API from (`liftClient`, `getClient`) to (`lift`, `lifted`) - Lift API is now `service.lift(resource, id: "name", allow: ["action"])`. didn't use `as` because it is highlighted as a special keyword in the IDE - Uses [asynclocalstorage](https://nodejs.org/api/async_context.html#class-asynclocalstorage) instead of req for storing and passing lifted clients context
- Loading branch information
Showing
13 changed files
with
51 additions
and
36 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
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,3 @@ | ||
import { Request } from 'express'; | ||
declare const lifted: (id: string) => any; | ||
|
||
declare const getClient: (req: Request, id: string) => any; | ||
|
||
export { getClient }; | ||
export { lifted }; |
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,20 +1,22 @@ | ||
module.exports.getClients = (req) => { | ||
return req.__wing_clients; | ||
}; | ||
const { AsyncLocalStorage } = require("node:async_hooks"); | ||
|
||
// this might run in a different context in sim | ||
const asyncLocalStorage = new AsyncLocalStorage(); | ||
global.asyncLocalStorage = asyncLocalStorage; | ||
|
||
/** | ||
* Get a Wing client from the request object. | ||
* @param {Object} req - The request object. | ||
* @param {string} id - The client Id. | ||
* @returns {Object} - The requested client. | ||
*/ | ||
module.exports.getClient = (req, id) => { | ||
if (!req.__wing_clients || !req.__wing_clients[id]) { | ||
module.exports.lifted = (id) => { | ||
const clients = global.asyncLocalStorage.getStore(); | ||
if (!clients || !clients[id]) { | ||
throw new Error(`Wing client ${id} not found`); | ||
} | ||
return req.__wing_clients[id]; | ||
return clients[id]; | ||
}; | ||
|
||
module.exports.setClients = (req, clients) => { | ||
req.__wing_clients = clients; | ||
module.exports.setLifted = (clients) => { | ||
global.asyncLocalStorage.enterWith(clients); | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,7 +1,7 @@ | ||
{ | ||
"name": "@winglibs/tsoa", | ||
"description": "TSOA library for Wing", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "Eyal Keren" | ||
|
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