Skip to content

Commit

Permalink
does it work?
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinJohnWilliams committed Apr 30, 2016
1 parent 8c9c587 commit 6d18ef7
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
17 changes: 17 additions & 0 deletions .editorconfig
@@ -0,0 +1,17 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,rb,css,html}]
indent_size = 2

[*.go]
indent_size = 8
indent_style = tab
11 changes: 0 additions & 11 deletions lib/config.js

This file was deleted.

10 changes: 6 additions & 4 deletions lib/words.js
@@ -1,3 +1,6 @@
import {
filter
} from 'lodash';
var _ = require('lodash');
var dict = require('./dictionary.js');

Expand All @@ -24,15 +27,14 @@ function search(word) {
toSearch = word.replace(/\//g, "");
}

var result = _.filter(dict.dictionary, function(w) {
var result = filter(dict.dictionary, w => {
return w.match(new RegExp(toSearch, "i"));
});

return {
result: result,
excludePattern: excludePattern,
result,
excludePattern,
searchPattern: toSearch
};
}

exports.search = search;
8 changes: 7 additions & 1 deletion package.json
Expand Up @@ -14,11 +14,17 @@
"body-parser": "^1.15.0",
"ejs": "~1.0.0",
"express": "~4.13.4",
"fs": "0.0.2",
"jasmine-node": "~1.11",
"lodash": "^4.11.1"
"lodash": "^4.11.1",
"net": "^1.0.2",
"webpack": "^1.13.0"
},
"subdomain": "word-finder",
"engines": {
"node": ">=0.8.x"
},
"devDependencies": {
"babel-core": "^6.7.7"
}
}
7 changes: 3 additions & 4 deletions server.js
@@ -1,11 +1,10 @@
require('babel-core/register');
var express = require('express');
var bodyParser = require('body-parser');
var _ = require('lodash');
var app = express();

var config = require('./lib/config');
var words = require('./lib/words');

app.set('view engine', 'ejs');
app.set('view options', { layout: false });
app.use('/public', express.static('public'));
Expand All @@ -22,5 +21,5 @@ app.post('/search', function (req, res) {
res.render('result', { words: result, pattern: req.body.pattern });
});

app.listen(process.env.PORT || config.port);
console.log("Listening on port: " + (process.env.PORT || config.port));
app.listen(process.env.PORT || 3000);
console.log("Listening on port: " + (process.env.PORT || 3000));
22 changes: 22 additions & 0 deletions webpack.config.js
@@ -0,0 +1,22 @@
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');

var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});

module.exports = {
entry: './server.js',
target: 'node',
output: {
path: path.join(__dirname, 'build'),
filename: 'backend.js'
},
externals: nodeModules
};

0 comments on commit 6d18ef7

Please sign in to comment.