Skip to content

Commit

Permalink
resolved conflict with response hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
briangormanly committed Oct 27, 2023
2 parents 9fdf6a1 + 4ff692c commit e60f27b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 35 deletions.
1 change: 1 addition & 0 deletions .bsp/sbt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"sbt","version":"1.8.2","bspVersion":"2.1.0-M1","languages":["scala"],"argv":["/Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home/bin/java","-Xms100m","-Xmx100m","-classpath","/opt/homebrew/Cellar/sbt/1.8.2/libexec/bin/sbt-launch.jar","-Dsbt.script=/opt/homebrew/Cellar/sbt/1.8.2/libexec/bin/sbt","xsbt.boot.Boot","-bsp"]}
67 changes: 34 additions & 33 deletions server/agora.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ app.use(
} )
);
app.use( bodyParser.json() );

app.use( responseHooks() );


Expand Down Expand Up @@ -54,26 +55,12 @@ app.use( express.static( publicPath ) );
// import uuid generator
const { v4: uuidv4 } = require( "uuid" );

// set up session
let session = require( "express-session" );
const pgSession = require( "connect-pg-simple" )( session );

// database connection
const db = require( "./db/connection" );

/**
* OpenAPI / Swagger
*/
const swaggerUi = require( "swagger-ui-express" );
const swaggerJsDoc = require( "swagger-jsdoc" );

// global swagger info (TODO: maybe this should be moved into another file if it is staying?)
const YAML = require( "yamljs" );
const swaggerApiDoc = YAML.load( "./server/agoraApi.yaml" );

// initialize swagger
//const swaggerDocInit = swaggerJsDoc( swaggerGlobal );
app.use( "/api-docs", swaggerUi.serve, swaggerUi.setup( swaggerApiDoc ) );
// set up session
let session = require( "express-session" );
const pgSession = require( "connect-pg-simple" )( session );

let sess = {
store: new pgSession( {
Expand Down Expand Up @@ -101,37 +88,34 @@ if ( app.get( "env" ) === "production" ) {

app.use( session( sess ) );

// check that the user is logged in, if so include user data in req for view


//check that the user is logged in, if so include user session data in req for view (ejs needs locals)
app.use( function ( req, res, next ) {
// set the currentUrl so it is available in the esj
res.locals.currentUrl = encodeURIComponent( req.url );

// if authenticated set the session as a local of the esj
if ( !req.session.isAuth ) {
next();
}
else {
res.locals.authUser = req.session.authUser;
next();
}
} );
// make the auth information available to the locals for ejs
res.locals.isAuth = req.session.isAuth;
res.locals.authUser = req.session.authUser;
next();

} );



/**
* Auth routes
*/
const authRoutes = require( "./routes/authRoutes" );
app.use( "/", authRoutes );

/**
* Page routes
*/
const pageRoutes = require( "./routes/pagesRoutes" );
app.use( "/", pageRoutes );

/**
* Auth routes
*/
const authRoutes = require( "./routes/authRoutes" );
app.use( "/", authRoutes );

/**
* User routes
*/
Expand Down Expand Up @@ -178,6 +162,23 @@ const { errorController } = require( "./controller/apis/apiErrorController" );
const ApiMessage = require( "./model/util/ApiMessage" );
app.use( "/api/v1/open", apiUnauthRoutes );


/**
* OpenAPI / Swagger
*/
const swaggerUi = require( "swagger-ui-express" );
const swaggerJsDoc = require( "swagger-jsdoc" );

// global swagger info (TODO: maybe this should be moved into another file if it is staying?)
const YAML = require( "yamljs" );
const swaggerApiDoc = YAML.load( "./server/agoraApi.yaml" );

// initialize swagger
//const swaggerDocInit = swaggerJsDoc( swaggerGlobal );
app.use( "/api-docs", swaggerUi.serve, swaggerUi.setup( swaggerApiDoc ) );



// // workspace
// let workspaceRoutes = require('./routes/community/workspaceRoutes');
// app.use('/community/workspace', workspaceRoutes);
Expand Down
2 changes: 1 addition & 1 deletion server/controller/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const signIn = async function( req, res ) {

// log the data
if( user && device ) {
userService.logUserSession( user.userId, ip, device );
await userService.logUserSession( user.userId, ip, device );

}
}
Expand Down
2 changes: 1 addition & 1 deletion server/service/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ exports.logUserSession = async function( userId, ipAddress, device ) {

try {

let response = await db.query( text, values );
await db.query( text, values );
return true;
}
catch( e ) {
Expand Down
2 changes: 2 additions & 0 deletions target/.history3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1677507046026:q
1677507049620:exit

0 comments on commit e60f27b

Please sign in to comment.