Skip to content

Commit

Permalink
feat: Create server entry-point
Browse files Browse the repository at this point in the history
see: #10
  • Loading branch information
sujinleeme committed Jul 1, 2018
1 parent 7f70df5 commit e13f3c7
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions server/app.js
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}`)
})

0 comments on commit e13f3c7

Please sign in to comment.