Checkout the example inside of the examples folder: /examples/index.js
eddiecooro / express-hooks Goto Github PK
View Code? Open in Web Editor NEWCustom hooks for use in express apps
License: MIT License
Custom hooks for use in express apps
License: MIT License
Checkout the example inside of the examples folder: /examples/index.js
Checks if the specified encoding is acceptable by the client
res.acceptsEncoding(encoding)
I have an idea of using a for loop over Object.keys(request) & Object.keys(response), where request & response are imported from the express package itself, for generating the hooks dynamically
We can also have an array of valid names and their hook equivalent in order to whitelisting request & response keys
checks if the specified language is acceptable by the client
req.acceptsLanguage(language)
returns the response object
returns the body of the request
req.body
Sets the specified cookie
res.cookie(cookieName, cookieValue, options)
Currently, Express middleware doesn't work correctly for async routes.
Because it sets the CurrentDispatcher back to null synchronously after calling next, which causes hooks to not work correctly inside of async routes
using lerna.
travis-ci will need additional configs
returns the host name
req.hostname
returns the specified cookie
req.cookies.name
(needs cookie parser)
checks if the specified charSet is acceptable by the client
res.acceptsCharset(charSet)
Appends the value to the header specified by the field
res.append(field, value)
returns the current HTTP method
req.method
checks if the specified contentType is acceptable by the client
req.accepts(contentType)
res.attechment(fileName)
returns the specified query parameter
req.query.queryName
returns the request object.
Webpack bundles our code by default, but it's not our expected behaviour, because in nodejs, we have cjs built-in.
So I wonder if we can make webpack to leave reqire statements as is and only convert esmodule imports/exports to their esmodule equivalents.
If we have to migrate completely to commonjs in order to achieve this, it's not a problem
returns the param specified by the paramName, returns defaultValue if param doesn't exist
req.params.paramName
returns the current path
req.path
returns the baseUrl
req.baseUrl
returns the specified header
req.get(headerName)
It should work as similar as possible to the native middlewares
returns value of the response header
res.get(name)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.