parent
e3883fecbd
commit
6ce88a1e3d
22
src/app.ts
22
src/app.ts
|
@ -7,21 +7,17 @@ import bodyparser from "body-parser";
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import routerMain from './routes/index';
|
import routerMain from './routes/index';
|
||||||
// const loaders = require('./loaders');
|
// const loaders = require('./loaders');
|
||||||
import * as loaders from './loaders/index';
|
import loaders from './loaders/index';
|
||||||
|
|
||||||
dotenvSafe.config();
|
dotenvSafe.config();
|
||||||
const app = express();
|
let app = express();
|
||||||
const PORT = process.env.APP_PORT || 4010;
|
const PORT = process.env.APP_PORT || 4010;
|
||||||
|
|
||||||
createConnection()
|
async function main() {
|
||||||
.then((connection) => {})
|
await loaders(app);
|
||||||
.catch((err) => {
|
app.listen(PORT, () => {
|
||||||
consola.error(err);
|
consola.success(`⚡️[server]: Server is running at http://localhost:${PORT}`);
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
// await loaders.init(app);
|
|
||||||
app.use('/api/', routerMain);
|
|
||||||
app.listen(PORT, () => {
|
|
||||||
consola.success(`⚡️[server]: Server is running at http://localhost:${PORT}`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
|
@ -0,0 +1,5 @@
|
||||||
|
import {createConnection} from "typeorm";
|
||||||
|
|
||||||
|
export default async ()=> {
|
||||||
|
return await createConnection();
|
||||||
|
};
|
|
@ -0,0 +1,14 @@
|
||||||
|
import {Application} from "express";
|
||||||
|
import bodyParser from 'body-parser';
|
||||||
|
import cors from 'cors';
|
||||||
|
|
||||||
|
export default async (app: Application) => {
|
||||||
|
app.get('/status', (req, res) => res.status(200).end());
|
||||||
|
app.enable('trust proxy');
|
||||||
|
|
||||||
|
app.use(cors());
|
||||||
|
// app.use(bodyParser.urlencoded({ extended: false }));
|
||||||
|
|
||||||
|
// more middlewares
|
||||||
|
return app;
|
||||||
|
};
|
|
@ -1,14 +1,11 @@
|
||||||
import express from 'express';
|
import expressLoader from "./express";
|
||||||
import bodyParser from 'body-parser';
|
import routeLoader from "./routes";
|
||||||
import cors from 'cors';
|
import databaseLoader from "./database";
|
||||||
|
import {Application} from "express";
|
||||||
|
|
||||||
export default async (app) => {
|
export default async (app: Application) => {
|
||||||
app.get('/status', (req, res) => res.status(200).end());
|
await expressLoader(app);
|
||||||
app.enable('trust proxy');
|
await routeLoader(app);
|
||||||
|
databaseLoader();
|
||||||
app.use(cors());
|
return app;
|
||||||
// app.use(bodyParser.urlencoded({ extended: false }));
|
|
||||||
|
|
||||||
// more middlewares
|
|
||||||
return app;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import {Application} from "express";
|
||||||
|
import routerMain from "../routes/index";
|
||||||
|
|
||||||
|
export default async (app: Application) => {
|
||||||
|
app.use('/api/', routerMain);
|
||||||
|
return app;
|
||||||
|
};
|
Loading…
Reference in New Issue