index.js
This commit is contained in:
commit
ff8012a459
5 changed files with 107 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
node_modules
|
||||
.idea
|
||||
.DS_Store
|
||||
|
49
bin/www
Executable file
49
bin/www
Executable file
|
@ -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;
|
||||
}
|
||||
|
13
index.js
Normal file
13
index.js
Normal file
|
@ -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
|
||||
|
27
package.json
Normal file
27
package.json
Normal file
|
@ -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"
|
||||
}
|
14
plugin/index.js
Normal file
14
plugin/index.js
Normal file
|
@ -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
|
||||
|
Loading…
Add table
Reference in a new issue