commit ff8012a459be58ed3c92194daf55e0cfe2afefe9 Author: Daniel Brahneborg Date: Mon Aug 12 09:29:15 2019 +0200 index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b097e7d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules +.idea +.DS_Store + diff --git a/bin/www b/bin/www new file mode 100755 index 0000000..cb5ee40 --- /dev/null +++ b/bin/www @@ -0,0 +1,49 @@ +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var app = require('../index'); +var debug = require('debug')('src:server'); +var http = require('http'); + +/** + * Get port from environment and store in Express. + */ + +var port = normalizePort(process.env.PORT || '3000'); +app.set('port', port); + +/** + * Create HTTP server. + */ + +var server = http.createServer(app); + +/** + * Listen on provided port, on all network interfaces. + */ + +server.listen(port); + +/** + * Normalize a port into a number, string, or false. + */ + +function normalizePort(val) { + var port = parseInt(val, 10); + + if (isNaN(port)) { + // named pipe + return val; + } + + if (port >= 0) { + // port number + return port; + } + + return false; +} + diff --git a/index.js b/index.js new file mode 100644 index 0000000..ebf338c --- /dev/null +++ b/index.js @@ -0,0 +1,13 @@ + +const express = require('express') +const app = express() +const path = require('path') + +app.use('/plugin', require('./plugin')) + +// catch 404 and forward to error handler +const createError = require('http-errors') +app.use(function(req, res, next) { next(createError(404)) }) + +module.exports = app + diff --git a/package.json b/package.json new file mode 100644 index 0000000..dc50a7a --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "pluginservice", + "version": "1.0.0", + "description": "EMG plugin API", + "main": "index.js", + "dependencies": { + "express": "^4.17.1", + "http-errors": "^1.7.3", + "nodemon": "^1.19.1" + }, + "devDependencies": { + "nodemon": "^1.19.1" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "./bin/www", + "dev": "npm start", + "nodemon": "./node_modules/nodemon/bin/nodemon.js --exec npm run dev" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@bitbucket.org/infoflexconnect/pluginservice.git" + }, + "author": "Daniel Brahneborg", + "license": "ISC", + "homepage": "https://bitbucket.org/infoflexconnect/pluginservice#readme" +} diff --git a/plugin/index.js b/plugin/index.js new file mode 100644 index 0000000..a14f339 --- /dev/null +++ b/plugin/index.js @@ -0,0 +1,14 @@ + +const express = require('express') +const router = express.Router() + +router.get('/', (req, res) => { + res.send('ok') +}) + +router.post('/before_receive', (req, res) => { + res.send('ok') +}) + +module.exports = router +