Created
December 16, 2021 00:45
-
-
Save lobot/0ba9cb2d411bbd4829bf65ee58e3bea9 to your computer and use it in GitHub Desktop.
webhook-basics-src-index.js
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
import express from "express"; | |
import mongoose from "mongoose"; | |
import cors from "cors"; | |
import path from "path"; | |
const app = express(); | |
const PORT = 3500; | |
const dbConnectionString = "mongodb://localhost:27017/lobwebhooks" | |
app.use(express.urlencoded({ extended: true })); | |
app.use(express.text()); | |
app.use(express.json({ type: "application/json" })); | |
app.use(cors()); | |
// Views and static files | |
app.set('views', path.join(__dirname, 'views')); | |
app.use(express.static(path.join(__dirname, 'views'))); | |
app.set('view engine', 'hbs'); | |
mongoose.connect(dbConnectionString, { useNewUrlParser: true, useUnifiedTopology: true }); | |
mongoose.connection.on("error", console.error.bind(console, "Connection Error:")); | |
// Require routes | |
const routes = require("./routes/web.js"); | |
app.use(routes); | |
app.listen(PORT,(error) => { | |
console.log(`Speak, I am listening on port ${PORT}`); | |
if(error){ | |
console.log(error); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment