caccl-dev-server 2.0.0-beta.10 → 2.0.0-beta.11

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/lib/index.d.ts CHANGED
@@ -10,5 +10,5 @@ import express from 'express';
10
10
  declare const serve: (opts: {
11
11
  app: express.Application;
12
12
  port: number;
13
- }) => void;
13
+ }) => Promise<void>;
14
14
  export default serve;
package/lib/index.js CHANGED
@@ -1,4 +1,40 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
40
  };
@@ -13,28 +49,31 @@ var https_1 = __importDefault(require("https"));
13
49
  * @param opts.app the express app to serve
14
50
  * @param [opts.port=8080] port number to serve on
15
51
  */
16
- var serve = function (opts) {
52
+ var serve = function (opts) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var app, port, pems, server;
17
54
  var _a;
18
- // Destructure opts
19
- var app = opts.app;
20
- var port = ((_a = opts.port) !== null && _a !== void 0 ? _a : 8080);
21
- // Generate certs
22
- var pems = selfsigned_1.default.generate({ name: "CACCL Dev Server on ".concat(port), value: "localhost:".concat(port) }, { days: 365 });
23
- // Create a server
24
- var server = https_1.default.createServer({ key: pems.private, cert: pems.cert }, app);
25
- // Start listening
26
- server.listen(port);
27
- server.on('listening', function () {
28
- console.log("Now listening on port ".concat(port));
55
+ return __generator(this, function (_b) {
56
+ app = opts.app;
57
+ port = ((_a = opts.port) !== null && _a !== void 0 ? _a : 8080);
58
+ pems = selfsigned_1.default.generate({ name: "CACCL Dev Server on ".concat(port), value: "localhost:".concat(port) }, { days: 365 });
59
+ server = https_1.default.createServer({ key: pems.private, cert: pems.cert }, app);
60
+ // Start listening
61
+ return [2 /*return*/, new Promise(function (resolve) {
62
+ server.listen(port);
63
+ server.on('listening', function () {
64
+ console.log("Now listening on port ".concat(port));
65
+ resolve(null);
66
+ });
67
+ server.on('error', function (err) {
68
+ if (err.message.includes('EADDRINUSE')) {
69
+ console.log("\nPort ".concat(port, " is already in use. Is another app already running?"));
70
+ process.exit(0);
71
+ }
72
+ console.log("\nCould not start simulator because an error occurred: ".concat(err.message));
73
+ process.exit(0);
74
+ });
75
+ })];
29
76
  });
30
- server.on('error', function (err) {
31
- if (err.message.includes('EADDRINUSE')) {
32
- console.log("\nPort ".concat(port, " is already in use. Is another app already running?"));
33
- process.exit(0);
34
- }
35
- console.log("\nCould not start simulator because an error occurred: ".concat(err.message));
36
- process.exit(0);
37
- });
38
- };
77
+ }); };
39
78
  exports.default = serve;
40
79
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AACA,0DAAoC;AACpC,gDAA0B;AAE1B;;;;;;;GAOG;AACH,IAAM,KAAK,GAAG,UACZ,IAGC;;IAED,mBAAmB;IACX,IAAA,GAAG,GAAK,IAAI,IAAT,CAAU;IACrB,IAAM,IAAI,GAAG,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,IAAI,CAAC,CAAC;IAEjC,iBAAiB;IACjB,IAAM,IAAI,GAAG,oBAAU,CAAC,QAAQ,CAC9B,EAAE,IAAI,EAAE,8BAAuB,IAAI,CAAE,EAAE,KAAK,EAAE,oBAAa,IAAI,CAAE,EAAE,EACnE,EAAE,IAAI,EAAE,GAAG,EAAE,CACd,CAAC;IAEF,kBAAkB;IAClB,IAAM,MAAM,GAAG,eAAK,CAAC,YAAY,CAC/B,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EACtC,GAAG,CACJ,CAAC;IAEF,kBAAkB;IAClB,MAAM,CAAC,MAA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AI,OAAO,CAAC,UAAC,OAAO;gBACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACpB,MAAM,CAAC,EAAE,CACP,WAAW,EACX;oBACE,OAAO,CAAC,GAAG,CAAC,gCAAyB,IAAI,CAAE,CAAC,CAAC;oBAC7C,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC,CACF,CAAC;gBACF,MAAM,CAAC,EAAE,CACP,OAAO,EACP,UAAC,GAAG;oBACF,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;wBACtC,OAAO,CAAC,GAAG,CAAC,iBAAU,IAAI,wDAAqD,CAAC,CAAC;wBACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;qBACjB;oBAED,OAAO,CAAC,GAAG,CAAC,iEAA0D,GAAG,CAAC,OAAO,CAAE,CAAC,CAAC;oBACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC,CACF,CAAC;YACJ,CAAC,CAAC,EAAC;;KACJ,CAAC;AAEF,kBAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caccl-dev-server",
3
- "version": "2.0.0-beta.10",
3
+ "version": "2.0.0-beta.11",
4
4
  "description": "HTTPS server for development of CACCL apps",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
package/src/index.ts CHANGED
@@ -10,12 +10,12 @@ import https from 'https';
10
10
  * @param opts.app the express app to serve
11
11
  * @param [opts.port=8080] port number to serve on
12
12
  */
13
- const serve = (
13
+ const serve = async (
14
14
  opts: {
15
15
  app: express.Application,
16
16
  port: number,
17
17
  },
18
- ) => {
18
+ ): Promise<void> => {
19
19
  // Destructure opts
20
20
  const { app } = opts;
21
21
  const port = (opts.port ?? 8080);
@@ -33,25 +33,28 @@ const serve = (
33
33
  );
34
34
 
35
35
  // Start listening
36
- server.listen(port);
37
- server.on(
38
- 'listening',
39
- () => {
40
- console.log(`Now listening on port ${port}`);
41
- },
42
- );
43
- server.on(
44
- 'error',
45
- (err) => {
46
- if (err.message.includes('EADDRINUSE')) {
47
- console.log(`\nPort ${port} is already in use. Is another app already running?`);
48
- process.exit(0);
49
- }
36
+ return new Promise((resolve) => {
37
+ server.listen(port);
38
+ server.on(
39
+ 'listening',
40
+ () => {
41
+ console.log(`Now listening on port ${port}`);
42
+ resolve(null);
43
+ },
44
+ );
45
+ server.on(
46
+ 'error',
47
+ (err) => {
48
+ if (err.message.includes('EADDRINUSE')) {
49
+ console.log(`\nPort ${port} is already in use. Is another app already running?`);
50
+ process.exit(0);
51
+ }
50
52
 
51
- console.log(`\nCould not start simulator because an error occurred: ${err.message}`);
52
- process.exit(0);
53
- },
54
- );
53
+ console.log(`\nCould not start simulator because an error occurred: ${err.message}`);
54
+ process.exit(0);
55
+ },
56
+ );
57
+ });
55
58
  };
56
59
 
57
60
  export default serve;