Created
June 16, 2017 00:19
-
-
Save unicodeveloper/8a23b474c5538869b7ca38850dc3fd85 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
require('dotenv').config(); | |
const express = require('express'); | |
const Logger = require('logdna'); | |
const app = express(); | |
const cors = require('cors'); | |
const bodyParser = require('body-parser'); | |
const options = { | |
hostname: 'your-host-name', | |
ip: 'your-ip-address', | |
mac: 'your-mac-address', | |
app: 'name-of-your-app', | |
}; | |
const log = Logger.setupDefaultLogger(process.env.key, options); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.use(cors()); | |
app.get('/api/test', (req, res) => { | |
res.json({ message: "Test that the URL is working" }); | |
}); | |
app.post('/api/log', (req, res) => { | |
log.info(`Application Name: ${req.body.app_name}`); | |
log.info(`Application Description: ${req.body.app_description}`); | |
console.log("Log something now"); | |
res.json({ message: "Logged something successfully" }); | |
}); | |
app.listen(7777); | |
console.log('Listening on localhost:7777'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment