mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(api): initial implementation of the auth system (#30)
Adds the auth system but does not add all required features. They will be handled in other tickets
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import express from 'express';
|
||||
import next from 'next';
|
||||
import { createConnection } from 'typeorm';
|
||||
import { createConnection, getRepository } from 'typeorm';
|
||||
import routes from './routes';
|
||||
import bodyParser from 'body-parser';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import session from 'express-session';
|
||||
import { TypeormStore } from 'connect-typeorm/out';
|
||||
import { Session } from './entity/Session';
|
||||
|
||||
const dev = process.env.NODE_ENV !== 'production';
|
||||
const app = next({ dev });
|
||||
@@ -13,6 +18,23 @@ app
|
||||
.prepare()
|
||||
.then(() => {
|
||||
const server = express();
|
||||
server.use(cookieParser());
|
||||
server.use(bodyParser.json());
|
||||
server.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
// Setup sessions
|
||||
const sessionRespository = getRepository(Session);
|
||||
server.use(
|
||||
session({
|
||||
secret: 'verysecret',
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
store: new TypeormStore({
|
||||
cleanupLimit: 2,
|
||||
ttl: 86400,
|
||||
}).connect(sessionRespository),
|
||||
})
|
||||
);
|
||||
server.use('/api', routes);
|
||||
server.get('*', (req, res) => handle(req, res));
|
||||
|
||||
|
Reference in New Issue
Block a user