11'use strict' ;
22
3- /**
4- * Lightweight web framework for your serverless applications
5- * @author Jeremy Daly <jeremy@jeremydaly.com>
6- * @version 0.11.0
7- * @license MIT
8- */
9-
10- const REQUEST = require ( './lib/request' ) ; // Resquest object
11- const RESPONSE = require ( './lib/response' ) ; // Response object
12- const UTILS = require ( './lib/utils' ) ; // Require utils library
13- const LOGGER = require ( './lib/logger' ) ; // Require logger library
14- const prettyPrint = require ( './lib/prettyPrint' ) ; // Pretty print for debugging
15- const { ConfigurationError } = require ( './lib/errors' ) ; // Require custom errors
16-
17- // Create the API class
3+ const REQUEST = require ( './lib/request' ) ;
4+ const RESPONSE = require ( './lib/response' ) ;
5+ const UTILS = require ( './lib/utils' ) ;
6+ const LOGGER = require ( './lib/logger' ) ;
7+ const prettyPrint = require ( './lib/prettyPrint' ) ;
8+ const { ConfigurationError } = require ( './lib/errors' ) ;
9+
1810class API {
19- // Create the constructor function.
2011 constructor ( props ) {
21- // Set the version and base paths
2212 this . _version = props && props . version ? props . version : 'v1' ;
2313 this . _base =
2414 props && props . base && typeof props . base === 'string'
@@ -51,16 +41,12 @@ class API {
5141 ? props . compression
5242 : false ;
5343
54- // Set sampling info
5544 this . _sampleCounts = { } ;
5645
57- // Init request counter
5846 this . _requestCount = 0 ;
5947
60- // Track init date/time
6148 this . _initTime = Date . now ( ) ;
6249
63- // Logging levels
6450 this . _logLevels = {
6551 trace : 10 ,
6652 debug : 20 ,
@@ -70,13 +56,11 @@ class API {
7056 fatal : 60 ,
7157 } ;
7258
73- // Configure logger
7459 this . _logger = LOGGER . config ( props && props . logger , this . _logLevels ) ;
7560
7661 // Prefix stack w/ base
7762 this . _prefix = this . parseRoute ( this . _base ) ;
7863
79- // Stores route mappings
8064 this . _routes = { } ;
8165
8266 // Init callback
@@ -94,7 +78,6 @@ class API {
9478 // Global error status (used for response parsing errors)
9579 this . _errorStatus = 500 ;
9680
97- // Methods
9881 this . _methods = [
9982 'get' ,
10083 'post' ,
@@ -110,7 +93,7 @@ class API {
11093 this . _methods . forEach ( ( m ) => {
11194 this [ m ] = ( ...a ) => this . METHOD ( m . toUpperCase ( ) , ...a ) ;
11295 } ) ;
113- } // end constructor
96+ }
11497
11598 // METHOD: Adds method, middleware, and handlers to routes
11699 METHOD ( method , ...args ) {
0 commit comments