blah
This commit is contained in:
		
							
								
								
									
										36
									
								
								src/test.mjs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/test.mjs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
import flummpress from '../dist/index.js';
 | 
			
		||||
 | 
			
		||||
process.on('unhandledRejection', err => {
 | 
			
		||||
  console.error(err);
 | 
			
		||||
  throw err;
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const app = new flummpress();
 | 
			
		||||
 | 
			
		||||
const loggedin = async (req, res, next) => {
 | 
			
		||||
  console.log("Logged in");
 | 
			
		||||
  await next();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
app.router.group(/^\/api\/v2\/admin\/(?<postid>\d+)\/tags/, group => {
 | 
			
		||||
  group.get(/$/,
 | 
			
		||||
    (req, res, next) => { // middleware davor
 | 
			
		||||
      console.log("Logged in");
 | 
			
		||||
      next();
 | 
			
		||||
    },
 | 
			
		||||
    (req, res, next) => { // eigentlicher request
 | 
			
		||||
      res.reply({
 | 
			
		||||
        body: JSON.stringify(req.params)
 | 
			
		||||
      });
 | 
			
		||||
      next();
 | 
			
		||||
    },
 | 
			
		||||
    (req, res) => { // middleware danach
 | 
			
		||||
      console.log("Logged out");
 | 
			
		||||
    }
 | 
			
		||||
  );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
app.listen(3000);
 | 
			
		||||
 | 
			
		||||
console.log(app.router);
 | 
			
		||||
		Reference in New Issue
	
	Block a user