diff --git a/striker-ui-api/src/app.ts b/striker-ui-api/src/app.ts index 5ee5d262..7a46c4ad 100644 --- a/striker-ui-api/src/app.ts +++ b/striker-ui-api/src/app.ts @@ -1,11 +1,9 @@ import cors from 'cors'; import express, { json } from 'express'; -import { guardApi } from './lib/assertAuthentication'; -import passport from './passport'; +import { guardApi, passport, session } from './middlewares'; import routes from './routes'; import { rrouters } from './lib/rrouters'; -import session from './session'; export default (async () => { const app = express(); diff --git a/striker-ui-api/src/lib/assertAuthentication.ts b/striker-ui-api/src/middlewares/assertAuthentication.ts similarity index 98% rename from striker-ui-api/src/lib/assertAuthentication.ts rename to striker-ui-api/src/middlewares/assertAuthentication.ts index 443dad37..172cb952 100644 --- a/striker-ui-api/src/lib/assertAuthentication.ts +++ b/striker-ui-api/src/middlewares/assertAuthentication.ts @@ -1,6 +1,6 @@ import { Handler } from 'express'; -import { stdout } from './shell'; +import { stdout } from '../lib/shell'; type HandlerParameters = Parameters; diff --git a/striker-ui-api/src/middlewares/index.ts b/striker-ui-api/src/middlewares/index.ts new file mode 100644 index 00000000..5cc3dad9 --- /dev/null +++ b/striker-ui-api/src/middlewares/index.ts @@ -0,0 +1,6 @@ +import passport from './passport'; +import session from './session'; + +export * from './assertAuthentication'; + +export { passport, session }; diff --git a/striker-ui-api/src/passport.ts b/striker-ui-api/src/middlewares/passport.ts similarity index 93% rename from striker-ui-api/src/passport.ts rename to striker-ui-api/src/middlewares/passport.ts index 66dba517..14065316 100644 --- a/striker-ui-api/src/passport.ts +++ b/striker-ui-api/src/middlewares/passport.ts @@ -1,11 +1,11 @@ import passport from 'passport'; import { Strategy as LocalStrategy } from 'passport-local'; -import { DELETED } from './lib/consts'; +import { DELETED } from '../lib/consts'; -import { query, sub } from './lib/accessModule'; -import { sanitize } from './lib/sanitize'; -import { stdout } from './lib/shell'; +import { query, sub } from '../lib/accessModule'; +import { sanitize } from '../lib/sanitize'; +import { stdout } from '../lib/shell'; passport.use( 'login', diff --git a/striker-ui-api/src/session.ts b/striker-ui-api/src/middlewares/session.ts similarity index 95% rename from striker-ui-api/src/session.ts rename to striker-ui-api/src/middlewares/session.ts index 309c84f8..aee9f288 100644 --- a/striker-ui-api/src/session.ts +++ b/striker-ui-api/src/middlewares/session.ts @@ -4,11 +4,11 @@ import expressSession, { Store as BaseSessionStore, } from 'express-session'; -import { DELETED } from './lib/consts'; +import { DELETED } from '../lib/consts'; -import { getLocalHostUUID, query, timestamp, write } from './lib/accessModule'; -import { getSessionSecret } from './lib/getSessionSecret'; -import { stderr, stdout, stdoutVar, uuid } from './lib/shell'; +import { getLocalHostUUID, query, timestamp, write } from '../lib/accessModule'; +import { getSessionSecret } from '../lib/getSessionSecret'; +import { stderr, stdout, stdoutVar, uuid } from '../lib/shell'; const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 28800000; // 8 hours diff --git a/striker-ui-api/src/routes/auth.ts b/striker-ui-api/src/routes/auth.ts index 5ffb8491..e48349cf 100644 --- a/striker-ui-api/src/routes/auth.ts +++ b/striker-ui-api/src/routes/auth.ts @@ -1,8 +1,7 @@ import express from 'express'; -import { guardApi } from '../lib/assertAuthentication'; import { login, logout } from '../lib/request_handlers/auth'; -import passport from '../passport'; +import { guardApi, passport } from '../middlewares'; const router = express.Router(); diff --git a/striker-ui-api/src/routes/static.ts b/striker-ui-api/src/routes/static.ts index 7538332f..32bc786b 100644 --- a/striker-ui-api/src/routes/static.ts +++ b/striker-ui-api/src/routes/static.ts @@ -4,7 +4,7 @@ import path from 'path'; import { SERVER_PATHS } from '../lib/consts'; -import { assertAuthentication } from '../lib/assertAuthentication'; +import { assertAuthentication } from '../middlewares'; import { stdout } from '../lib/shell'; const router = express.Router();