Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 64 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | const feathers = require('feathers') |
||
2 | const rest = require('feathers-rest') |
||
3 | const bodyParser = require('body-parser') |
||
4 | const socketio = require('feathers-socketio') |
||
5 | const memory = require('feathers-memory') |
||
6 | |||
7 | // Patch in {like: 'var'} ability to feathers-memory query |
||
8 | require('feathers-commons/lib/utils').specialFilters.$like = function (key, value) { |
||
9 | value = value.toString().toLowerCase() |
||
10 | return function (current) { |
||
11 | return current[key].toString().toLowerCase().indexOf(value) !== -1 |
||
12 | } |
||
13 | } |
||
14 | |||
15 | const app = feathers() |
||
16 | |||
17 | app.configure(rest()) |
||
18 | app.configure(socketio()) |
||
19 | |||
20 | app.use(bodyParser.json()) |
||
21 | app.use(bodyParser.urlencoded({extended: true})) |
||
22 | |||
23 | app.service('todos', memory({ |
||
24 | startId: 2, |
||
25 | store: { |
||
26 | 1: { |
||
27 | id: 1, |
||
28 | title: 'Test Todo', |
||
29 | completed: false |
||
30 | } |
||
31 | } |
||
32 | })) |
||
33 | |||
34 | app.service('countries', memory({ |
||
35 | /* Paginate: { |
||
36 | default: 25, |
||
37 | max: 50, |
||
38 | }, */ |
||
39 | })) |
||
40 | |||
41 | // Webpack server |
||
42 | const webpack = require('webpack') |
||
43 | const webpackConfig = require('./webpack.config') |
||
44 | |||
45 | const compiler = webpack(webpackConfig) |
||
46 | |||
47 | app.use(require('webpack-dev-middleware')(compiler, { |
||
48 | publicPath: webpackConfig.output.publicPath, |
||
49 | noInfo: true, |
||
50 | stats: { |
||
51 | colors: true |
||
52 | } |
||
53 | })) |
||
54 | app.use(require('webpack-hot-middleware')(compiler)) |
||
55 | |||
56 | // Static files |
||
57 | app.use('/', feathers.static(__dirname)) |
||
58 | |||
59 | // Seed with data |
||
60 | app.service('countries').create(require('country-data').countries.all) |
||
61 | |||
62 | app.listen(8030, () => { |
||
63 | console.log('Serving examples on http://localhost:8030') |
||
64 | }) |
||
65 |