feat: added anime router
This commit is contained in:
+17
-2
@@ -5,10 +5,13 @@ import express, {
|
|||||||
ErrorRequestHandler,
|
ErrorRequestHandler,
|
||||||
Application,
|
Application,
|
||||||
} from "express";
|
} from "express";
|
||||||
|
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
import morgan from "morgan";
|
import morgan from "morgan";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
|
|
||||||
|
import animeRouter from "./routes";
|
||||||
|
|
||||||
config();
|
config();
|
||||||
const app: Application = express();
|
const app: Application = express();
|
||||||
const PORT: number = Number(process.env.PORT) || 4000;
|
const PORT: number = Number(process.env.PORT) || 4000;
|
||||||
@@ -16,8 +19,20 @@ const PORT: number = Number(process.env.PORT) || 4000;
|
|||||||
app.use(morgan("dev"));
|
app.use(morgan("dev"));
|
||||||
|
|
||||||
app.get("/", (req: Request, res: Response) => {
|
app.get("/", (req: Request, res: Response) => {
|
||||||
res.json("hi there");
|
res.send(`
|
||||||
|
<body style="font-family: sans-serif; background: #000; color: #FFF;">
|
||||||
|
<h3>Welcome to Zoro.to api ⚔️</h3>
|
||||||
|
<a
|
||||||
|
style="color: #00AEDD;"
|
||||||
|
href="https://github.com/ghoshRitesh12/zoro.to-api#readme"
|
||||||
|
rel="noopener noreferer"
|
||||||
|
>
|
||||||
|
Visit docs for more into
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
`);
|
||||||
});
|
});
|
||||||
|
app.use("/anime", animeRouter);
|
||||||
|
|
||||||
app.use((req: Request, res: Response, next: NextFunction) =>
|
app.use((req: Request, res: Response, next: NextFunction) =>
|
||||||
next(createHttpError.NotFound())
|
next(createHttpError.NotFound())
|
||||||
@@ -33,5 +48,5 @@ const errorHandler: ErrorRequestHandler = (error, req, res, next) => {
|
|||||||
app.use(errorHandler);
|
app.use(errorHandler);
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`⚔ api @ http://localhost:${PORT}`);
|
console.log(`⚔️ api @ http://localhost:${PORT}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user