UNPKG

apisculptify

Version:

Apisculptify is a powerful Node.js tool designed to automate the process of generating RESTful APIs for your TypeORM models. With Apisculptify, you can quickly create a new project, define your TypeORM models, and effortlessly generate CRUD (Create, Read,

30 lines (22 loc) 813 B
import express from "express"; import { myDataSource } from "./db/db.config"; const swaggerUi = require('swagger-ui-express'); const swaggerDocument = require('./swagger.json'); const app = express(); app.use(express.json()) //configure your routes like following example //app.use("/user", UserRouter) //app.use("/address", UserAddressRouter) app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); app.get('/api-docs-json', (req, res) => res.status(200).json(swaggerDocument)); const port = 4011; myDataSource.initialize() .then(() => { console.log("Data Source has been initialized!") }) .catch((err) => { console.error("Error during Data Source initialization:", err) }) app.listen(port, (): void => { console.log("server is running on" + port); })