mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat: bootstrap the basic app structure
This commit is contained in:
31
server/index.ts
Normal file
31
server/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import express from 'express';
|
||||
import next from 'next';
|
||||
import { createConnection } from 'typeorm';
|
||||
|
||||
const dev = process.env.NODE_ENV !== 'production';
|
||||
const app = next({ dev });
|
||||
const handle = app.getRequestHandler();
|
||||
|
||||
createConnection();
|
||||
|
||||
app
|
||||
.prepare()
|
||||
.then(() => {
|
||||
const server = express();
|
||||
server.get('/api', (req, res) => {
|
||||
res.json({ worked: true });
|
||||
});
|
||||
server.get('*', (req, res) => handle(req, res));
|
||||
|
||||
const port = Number(process.env.PORT) || 3000;
|
||||
server.listen(port, (err) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
console.log(`Ready to do stuff http://localhost:${port}`);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err.stack);
|
||||
process.exit(1);
|
||||
});
|
Reference in New Issue
Block a user