Skip to content

Instantly share code, notes, and snippets.

@mikaelkaron
Last active February 22, 2017 10:42
Show Gist options
  • Save mikaelkaron/d10ee3863a6f0773c5386b77abea77fa to your computer and use it in GitHub Desktop.
Save mikaelkaron/d10ee3863a6f0773c5386b77abea77fa to your computer and use it in GitHub Desktop.
microcule-docker
.*
!/.gitignore
node_modules
FROM node:boron
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
# Expose port
EXPOSE 3000
EXPOSE 5858
ENTRYPOINT ["npm", "start"]
var microcule = require('microcule');
var plugins = microcule.plugins;
var app = require('express')();
app.use(plugins.bodyParser());
app.use("/request/hook", plugins.spawn({
code: require("./request.hook"),
language: "javascript",
customTimeout: 2147483647
}));
app.use("/scrape/hook", plugins.spawn({
code: require("./scrape.hook"),
language: "javascript",
customTimeout: 2147483647
}));
app.use("/scrape/middleware", require("./scrape.middleware"));
app.listen(3000, function () {
console.log('server started on port 3000');
});
{
"name": "microcule-docker",
"version": "0.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"express": "^4.14.1",
"microcule": "^5.0.1",
"request-x-ray": "^0.1.4",
"x-ray": "^2.3.1"
}
}
module.exports = function (hook) {
require('request')({
"url": "http://www.eventsinamerica.com/event-search-results.html",
"method": "post",
"qs": {
"ipp": 100000,
"show_old": "include",
"parent_industry": "technology"
}
})
.pipe(hook.res);
};
module.exports = function (hook) {
var x = require('x-ray')();
x.driver(require('request-x-ray')({
"method": "post",
"qs": {
"ipp": 100000,
"show_old": "include",
"parent_industry": "technology"
}
}));
x("http://www.eventsinamerica.com/event-search-results.html", {
"title": "title",
"results": x("#present-events tr", [{
"event": "a",
"url": "a@href"
}])
})
.stream()
.pipe(hook.res);
};
module.exports = function (req, res) {
var x = require('x-ray')();
x.driver(require('request-x-ray')({
"method": "post",
"qs": {
"ipp": 100000,
"show_old": "include",
"parent_industry": "technology"
}
}));
x("http://www.eventsinamerica.com/event-search-results.html", {
"title": "title",
"results": x("#present-events tr", [{
"event": "a",
"url": "a@href"
}])
})
.stream()
.pipe(res);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment