-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User defined imports name mangling #1865
base: main
Are you sure you want to change the base?
Changes from all commits
007555f
2990d1f
3cc6250
7baeb37
157202e
dbd8546
92e3e0b
5d75bd2
cc71b8a
c24bbf1
c86dd79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,10 @@ export type { MiddlewareConfig, MiddlewareConfigFn } from 'wasp/server/middlewar | |
|
||
{=# globalMiddlewareConfigFn.isDefined =} | ||
{=& globalMiddlewareConfigFn.importStatement =} | ||
const globalMiddlewareConfigFn = {= globalMiddlewareConfigFn.importIdentifier =} | ||
{=/ globalMiddlewareConfigFn.isDefined =} | ||
{=^ globalMiddlewareConfigFn.isDefined =} | ||
const {=& globalMiddlewareConfigFn.importAlias =} = (mc: MiddlewareConfig) => mc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for a custom alias anymore 😄 |
||
const globalMiddlewareConfigFn = (mc: MiddlewareConfig) => mc | ||
{=/ globalMiddlewareConfigFn.isDefined =} | ||
|
||
// This is the set of middleware Wasp supplies by default. | ||
|
@@ -29,7 +30,7 @@ const defaultGlobalMiddlewareConfig: MiddlewareConfig = new Map([ | |
|
||
// This is the global middleware that is the result of applying the user's modifications. | ||
// It will be used as the basis for Operations and APIs (unless they are further customized). | ||
const globalMiddlewareConfig: MiddlewareConfig = {=& globalMiddlewareConfigFn.importAlias =}(defaultGlobalMiddlewareConfig) | ||
const globalMiddlewareConfig: MiddlewareConfig = globalMiddlewareConfigFn(defaultGlobalMiddlewareConfig) | ||
|
||
// This function returns an array of Express middleware to be used by a router. It optionally | ||
// accepts a function that can modify the global middleware for specific route customization. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,32 +9,32 @@ import { type AuthUser } from 'wasp/auth' | |
{=/ isAuthEnabled =} | ||
|
||
{=# apiNamespaces =} | ||
{=& namespaceMiddlewareConfigFnImportStatement =} | ||
{=& namespaceMiddlewareConfigFn.importStatement =} | ||
{=/ apiNamespaces =} | ||
|
||
{=# apiRoutes =} | ||
{=& importStatement =} | ||
{=& apiRouteFn.importStatement =} | ||
{=# routeMiddlewareConfigFn.isDefined =} | ||
{=& routeMiddlewareConfigFn.importStatement =} | ||
{=/ routeMiddlewareConfigFn.isDefined =} | ||
{=/ apiRoutes =} | ||
|
||
const idFn: MiddlewareConfigFn = x => x | ||
|
||
{=# apiRoutes =} | ||
{=^ routeMiddlewareConfigFn.isDefined =} | ||
const {=& routeMiddlewareConfigFn.importAlias =} = idFn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for custom aliases anymore, rewrote this code to work with the new mangling. |
||
{=/ routeMiddlewareConfigFn.isDefined =} | ||
{=/ apiRoutes =} | ||
|
||
const router = express.Router() | ||
|
||
{=# apiNamespaces =} | ||
router.use('{= namespacePath =}', globalMiddlewareConfigForExpress({= namespaceMiddlewareConfigFnImportAlias =})) | ||
router.use('{= namespacePath =}', globalMiddlewareConfigForExpress({= namespaceMiddlewareConfigFn.importIdentifier =})) | ||
{=/ apiNamespaces =} | ||
|
||
{=# apiRoutes =} | ||
const {= apiName =}Middleware = globalMiddlewareConfigForExpress({= routeMiddlewareConfigFn.importAlias =}) | ||
{=# routeMiddlewareConfigFn.isDefined =} | ||
const {= apiName =}Middleware = globalMiddlewareConfigForExpress({= routeMiddlewareConfigFn.importIdentifier =}) | ||
{=/ routeMiddlewareConfigFn.isDefined =} | ||
{=^ routeMiddlewareConfigFn.isDefined =} | ||
const {= apiName =}Middleware = globalMiddlewareConfigForExpress(idFn) | ||
{=/ routeMiddlewareConfigFn.isDefined =} | ||
|
||
router.{= routeMethod =}( | ||
'{= routePath =}', | ||
{=# usesAuth =} | ||
|
@@ -45,8 +45,8 @@ router.{= routeMethod =}( | |
{=/ usesAuth =} | ||
handleRejection( | ||
( | ||
req: Parameters<typeof {= importIdentifier =}>[0]{=# usesAuth =} & { user: AuthUser }{=/ usesAuth =}, | ||
res: Parameters<typeof {= importIdentifier =}>[1], | ||
req: Parameters<typeof {= apiRouteFn.importIdentifier =}>[0]{=# usesAuth =} & { user: AuthUser }{=/ usesAuth =}, | ||
res: Parameters<typeof {= apiRouteFn.importIdentifier =}>[1], | ||
) => { | ||
const context = { | ||
{=# usesAuth =} | ||
|
@@ -58,7 +58,7 @@ router.{= routeMethod =}( | |
{=/ entities =} | ||
}, | ||
} | ||
return {= importIdentifier =}(req, res, context) | ||
return {= apiRouteFn.importIdentifier =}(req, res, context) | ||
} | ||
) | ||
) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we reference the import name in the CLI, we had to adjust the code a bit.