2022-03-06 19:46:59 -05:00
|
|
|
import * as express from 'express';
|
|
|
|
import * as bodyParser from 'body-parser';
|
|
|
|
import * as errorhandler from 'strong-error-handler';
|
|
|
|
import * as cors from 'cors';
|
2022-03-11 21:48:40 -05:00
|
|
|
import { posts, users, auth, files } from './routes';
|
2022-03-06 19:46:59 -05:00
|
|
|
|
|
|
|
export const app = express();
|
|
|
|
|
|
|
|
app.use(bodyParser.urlencoded({ extended: true }));
|
|
|
|
app.use(bodyParser.json({ limit: '5mb' }));
|
|
|
|
|
|
|
|
const corsOptions = {
|
|
|
|
origin: `http://localhost:3001`,
|
|
|
|
};
|
|
|
|
app.use(cors(corsOptions));
|
|
|
|
|
2022-03-10 02:46:59 -05:00
|
|
|
app.use("/auth", auth)
|
2022-03-06 19:46:59 -05:00
|
|
|
app.use("/posts", posts)
|
2022-03-10 02:46:59 -05:00
|
|
|
app.use("/users", users)
|
2022-03-11 21:48:40 -05:00
|
|
|
app.use("/files", files)
|
2022-03-06 19:46:59 -05:00
|
|
|
|
|
|
|
app.use(errorhandler({
|
|
|
|
debug: process.env.ENV !== 'production',
|
|
|
|
log: true,
|
|
|
|
}));
|