redweb 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -10,6 +10,8 @@ const DEFAULT_OPTIONS = {
10
10
  listenCallback: undefined
11
11
  }
12
12
 
13
+ const METHODS = {'POST': 'post', 'GET': 'get'}
14
+
13
15
  /**
14
16
  * To get started with RedWeb, simply initialize your RedWeb instance:
15
17
  * ```javascript
@@ -27,16 +29,17 @@ const DEFAULT_OPTIONS = {
27
29
  * );
28
30
  * ```
29
31
  *
30
- * @param {{port: Number, bind: String, public: Array<String>, services: []}} options
32
+ * @param {{port: Number, bind: String, publicPaths: Array<String>, services: Array<{serviceName: String, method: String, function: Function}>}} options
31
33
  * @return RedWeb
32
34
  */
33
35
  function RedWeb(options = DEFAULT_OPTIONS) {
34
36
  const app = express();
35
37
  const { publicPaths, port, listenCallback, services } = options;
36
38
  app.use(bodyParser.json());
39
+ services.forEach((service) => app[service.method](service.serviceName, service.function));
37
40
  publicPaths.forEach((public_path) => app.use(express.static(path.join(__dirname, '../../', public_path))));
38
41
  app.listen(port, listenCallback ? listenCallback : () => console.log('RedWeb listening on port ' + options.port));
39
42
  return this;
40
43
  }
41
44
 
42
- module.exports = { RedWeb }
45
+ module.exports = { RedWeb, METHODS }
package/index.test.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const { RedWeb } = require('.');
2
+ const path = require('path');
2
3
 
3
4
  jest.mock('express', () => {
4
5
  const self = () => ({
@@ -11,4 +12,4 @@ jest.mock('express', () => {
11
12
 
12
13
  test('it should create a RedWeb instance', () => {
13
14
  expect(RedWeb()).toBeDefined();
14
- })
15
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redweb",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A way to quickly set up an express server",
5
5
  "main": "index.js",
6
6
  "scripts": {