mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
41 lines
980 B
TypeScript
41 lines
980 B
TypeScript
import path from 'path';
|
|
import cookieParser from 'cookie-parser';
|
|
import cors from 'cors';
|
|
import express from 'express';
|
|
import passport from 'passport';
|
|
import 'express-async-errors';
|
|
import { errorHandler } from '@/middleware';
|
|
import { routes } from '@routes/index';
|
|
|
|
require('./lib/passport');
|
|
|
|
const PORT = 9321;
|
|
|
|
const app = express();
|
|
const staticPath = path.join(__dirname, '../feishin-client/');
|
|
|
|
app.use(express.static(staticPath));
|
|
app.use(
|
|
cors({
|
|
credentials: false,
|
|
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
|
origin: [`http://localhost:4343`, `${process.env.APP_BASE_URL}`],
|
|
})
|
|
);
|
|
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: false }));
|
|
app.use(cookieParser());
|
|
|
|
app.use(passport.initialize());
|
|
app.use(passport.session());
|
|
|
|
app.get('/', (_req, res) => {
|
|
res.sendFile(path.join(staticPath, 'index.html'));
|
|
});
|
|
|
|
app.use(routes);
|
|
app.use(errorHandler);
|
|
|
|
app.listen(9321, () => console.log(`Listening on port ${PORT}`));
|