refactor(striker-ui-api): organize middlewares

main
Tsu-ba-me 2 years ago
parent 0b304251ff
commit ab4a4cee9a
  1. 4
      striker-ui-api/src/app.ts
  2. 2
      striker-ui-api/src/middlewares/assertAuthentication.ts
  3. 6
      striker-ui-api/src/middlewares/index.ts
  4. 8
      striker-ui-api/src/middlewares/passport.ts
  5. 8
      striker-ui-api/src/middlewares/session.ts
  6. 3
      striker-ui-api/src/routes/auth.ts
  7. 2
      striker-ui-api/src/routes/static.ts

@ -1,11 +1,9 @@
import cors from 'cors'; import cors from 'cors';
import express, { json } from 'express'; import express, { json } from 'express';
import { guardApi } from './lib/assertAuthentication'; import { guardApi, passport, session } from './middlewares';
import passport from './passport';
import routes from './routes'; import routes from './routes';
import { rrouters } from './lib/rrouters'; import { rrouters } from './lib/rrouters';
import session from './session';
export default (async () => { export default (async () => {
const app = express(); const app = express();

@ -1,6 +1,6 @@
import { Handler } from 'express'; import { Handler } from 'express';
import { stdout } from './shell'; import { stdout } from '../lib/shell';
type HandlerParameters = Parameters<Handler>; type HandlerParameters = Parameters<Handler>;

@ -0,0 +1,6 @@
import passport from './passport';
import session from './session';
export * from './assertAuthentication';
export { passport, session };

@ -1,11 +1,11 @@
import passport from 'passport'; import passport from 'passport';
import { Strategy as LocalStrategy } from 'passport-local'; import { Strategy as LocalStrategy } from 'passport-local';
import { DELETED } from './lib/consts'; import { DELETED } from '../lib/consts';
import { query, sub } from './lib/accessModule'; import { query, sub } from '../lib/accessModule';
import { sanitize } from './lib/sanitize'; import { sanitize } from '../lib/sanitize';
import { stdout } from './lib/shell'; import { stdout } from '../lib/shell';
passport.use( passport.use(
'login', 'login',

@ -4,11 +4,11 @@ import expressSession, {
Store as BaseSessionStore, Store as BaseSessionStore,
} from 'express-session'; } from 'express-session';
import { DELETED } from './lib/consts'; import { DELETED } from '../lib/consts';
import { getLocalHostUUID, query, timestamp, write } from './lib/accessModule'; import { getLocalHostUUID, query, timestamp, write } from '../lib/accessModule';
import { getSessionSecret } from './lib/getSessionSecret'; import { getSessionSecret } from '../lib/getSessionSecret';
import { stderr, stdout, stdoutVar, uuid } from './lib/shell'; import { stderr, stdout, stdoutVar, uuid } from '../lib/shell';
const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 28800000; // 8 hours const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 28800000; // 8 hours

@ -1,8 +1,7 @@
import express from 'express'; import express from 'express';
import { guardApi } from '../lib/assertAuthentication';
import { login, logout } from '../lib/request_handlers/auth'; import { login, logout } from '../lib/request_handlers/auth';
import passport from '../passport'; import { guardApi, passport } from '../middlewares';
const router = express.Router(); const router = express.Router();

@ -4,7 +4,7 @@ import path from 'path';
import { SERVER_PATHS } from '../lib/consts'; import { SERVER_PATHS } from '../lib/consts';
import { assertAuthentication } from '../lib/assertAuthentication'; import { assertAuthentication } from '../middlewares';
import { stdout } from '../lib/shell'; import { stdout } from '../lib/shell';
const router = express.Router(); const router = express.Router();

Loading…
Cancel
Save