refactor: request.(socket|page)
This commit is contained in:
parent
9cb130d776
commit
7a47af1c37
|
@ -25,10 +25,10 @@ export default {
|
|||
'@latus/db/server/models': gatherWithLatus(
|
||||
require.context('./models', false, /\.js$/),
|
||||
),
|
||||
'@latus/http/server/request': (latus) => {
|
||||
'@latus/http/server/request.page': (latus) => {
|
||||
const {config: {'@latus/governor/server': {http}}} = latus;
|
||||
const limiter = createLimiter(latus, {
|
||||
keyPrefix: '@latus/http/server/request',
|
||||
keyPrefix: '@latus/http/server/request.page',
|
||||
...http,
|
||||
});
|
||||
return async (req, res, next) => {
|
||||
|
|
|
@ -31,8 +31,11 @@ export const createHttpServer = async (latus) => {
|
|||
const httpServer = createServer(app);
|
||||
latus.set('%http', httpServer);
|
||||
httpServer.app = app;
|
||||
app.use((req, res, next) => {
|
||||
latus.invokeMiddleware('@latus/http/server/request.socket', req, res, next);
|
||||
});
|
||||
const requestMiddleware = (req, res, next) => {
|
||||
latus.invokeMiddleware('@latus/http/server/request', req, res, next);
|
||||
latus.invokeMiddleware('@latus/http/server/request.page', req, res, next);
|
||||
};
|
||||
const routes = arrayFlatten(latus.invokeFlat('@latus/http/routes'));
|
||||
routes.forEach(({method, path, handler}) => app[method](path, requestMiddleware, handler));
|
||||
|
|
|
@ -40,7 +40,8 @@ export default {
|
|||
devPublic: undefined,
|
||||
host: '0.0.0.0',
|
||||
port: 32340,
|
||||
request: [],
|
||||
'request.page': [],
|
||||
'request.socket': [],
|
||||
trust: false,
|
||||
}),
|
||||
'@latus/core/server/up': (latus) => createHttpServer(latus),
|
||||
|
|
|
@ -26,7 +26,7 @@ const adapterIntoReq = (path, adapter, req) => {
|
|||
|
||||
export default {
|
||||
hooks: {
|
||||
'@latus/http/server/request': ({config: {'%redisAdapter': adapter}}) => (req, res, next) => {
|
||||
'@latus/http/server/request.socket': ({config: {'%redisAdapter': adapter}}) => (req, res, next) => {
|
||||
adapterIntoReq('http', adapter, req);
|
||||
next();
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@ export default {
|
|||
'@latus/db/server/models': gatherWithLatus(
|
||||
require.context('./models', false, /\.js$/),
|
||||
),
|
||||
'@latus/http/server/request': (latus) => (req, res, next) => {
|
||||
'@latus/http/server/request.page': (latus) => (req, res, next) => {
|
||||
debug('@latus/http/server/request: passport.initialize()');
|
||||
passport.initialize()(req, res, () => {
|
||||
debug('@latus/http/server/request: passport.session()');
|
||||
|
|
|
@ -15,7 +15,7 @@ export default {
|
|||
...latus.invokeReduce('@latus/user/session'),
|
||||
}));
|
||||
},
|
||||
'@latus/http/server/request': (latus) => {
|
||||
'@latus/http/server/request.page': (latus) => {
|
||||
const urle = express.urlencoded({extended: true});
|
||||
return (req, res, next) => {
|
||||
debug('@latus/http/server/request: express.urlencoded()');
|
||||
|
|
Loading…
Reference in New Issue
Block a user