initial commit - far from runnable
This commit is contained in:
commit
db057ce342
8614 changed files with 1032171 additions and 0 deletions
34
src/index.ts
Normal file
34
src/index.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { AppDataSource } from "./data-source"
|
||||
import * as express from "express";
|
||||
import * as dotenv from "dotenv";
|
||||
import { Request, Response } from "express";
|
||||
import { authPoint } from "./endpoints/authPoint";
|
||||
import { userPoint } from "./endpoints/userPoint";
|
||||
import { recipePoint } from "./endpoints/recipePoint";
|
||||
import {errorHandler} from "./middleware/errorHandler"
|
||||
import "reflect-metadata";
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use(errorHandler);
|
||||
|
||||
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
||||
const HOST = process.env.HOST || "localhost";
|
||||
|
||||
app.use("/auth", authPoint);
|
||||
app.use("/user", userPoint);
|
||||
app.use("/recipe", recipePoint);
|
||||
|
||||
app.get("*", (req: Request, res: Response) => {
|
||||
res.status(505).json({ message: "Bad Request" });
|
||||
});
|
||||
|
||||
AppDataSource.initialize()
|
||||
.then(async () => {
|
||||
app.listen(PORT, HOST, () => {
|
||||
console.log(`Server is running on http://${HOST}:${PORT}`);
|
||||
});
|
||||
console.log("Data Source has been initialized!");
|
||||
})
|
||||
.catch((error) => console.log(error));
|
||||
Loading…
Add table
Add a link
Reference in a new issue