Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Created June 16, 2017 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unicodeveloper/8a23b474c5538869b7ca38850dc3fd85 to your computer and use it in GitHub Desktop.
Save unicodeveloper/8a23b474c5538869b7ca38850dc3fd85 to your computer and use it in GitHub Desktop.
'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