-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** require dependencies */ | ||
const express = require("express") | ||
const routes = require("./routes/") | ||
const mongoose = require("mongoose") | ||
const cors = require("cors") | ||
const bodyParser = require("body-parser") | ||
const helmet = require("helmet") | ||
// const cloudinary = require("cloudinary") | ||
|
||
const app = express() | ||
const router = express.Router() | ||
const url = process.env.MONGODB_URI || "mongodb://localhost:27017/vocal-remover-app" | ||
|
||
/** connect to MongoDB datastore */ | ||
try { | ||
mongoose.connect(url, { | ||
//useMongoClient: true | ||
}) | ||
} catch (error) { | ||
|
||
} | ||
|
||
let port = 5000 || process.env.PORT | ||
|
||
/** set up routes {API Endpoints} */ | ||
routes(router) | ||
|
||
/** set up middlewares */ | ||
app.use(cors()) | ||
app.use(bodyParser.json()) | ||
app.use(helmet()) | ||
//app.use('/static',express.static(path.join(__dirname,'static'))) | ||
|
||
|
||
app.get('/', (req, res) => { | ||
const help = ` | ||
<pre> | ||
Welcome to Vocal Remover for Karaoke API! | ||
</pre> | ||
` | ||
res.send(help) | ||
}) | ||
|
||
|
||
app.use("/api", router) | ||
|
||
/** start server */ | ||
app.listen(port, () => { | ||
console.log(`Server started at port: ${port}`) | ||
}) |