new SGAppsServer(optionsopt)
- Source:
HTTP Server for high performance results
Examples
// ================================
// Start your ๐ Web-Server app
// ================================
const { SGAppsServer } = require('@sgapps.io/server');
const app = new SGAppsServer();
app.get('/', function (req, res) {
res.send('hello world')
})
app.server().listen(8080, () => {
app.logger.log('Server is running on port 8080');
})
// ========================================
// Start your ๐ Web-Server app Extended
// ========================================
const { SGAppsServer } = require('@sgapps.io/server');
const app = new SGAppsServer();
app.get('/', function (req, res) {
res.send('hello world')
})
app.whenReady.then(() => {
app.SessionManager.cookie = 'ssid';
app.SessionManager.SESSION_LIFE = 120; // seconds
app.server().listen(8080, () => {
app.logger.log('Server is running on port 8080');
})
}, app.logger.error);
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
Classes
Members
_decorators :Array.<SGAppsServerDecorator>
- Source:
Type:
- Array.<SGAppsServerDecorator>
_fs :object
- Source:
Type:
- object
_options :SGAppsServerOptions
- Source:
Type:
_path :object
- Source:
Type:
- object
_requestListeners :Object.<string, SGAppsServerDictionary>
- Source:
Type:
- Object.<string, SGAppsServerDictionary>
_server :Server
- Source:
Type:
- Server
AccessLogger :AccessLogger
- Source:
Type:
AccessLoggerPaths :Object.<string, AccessLogger.AccessLoggerPath>
- Source:
Type:
- Object.<string, AccessLogger.AccessLoggerPath>
CookiesManager :object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
COOKIES_KEY |
string | |||
_enabled |
boolean |
<optional> |
true
|
if is changed to false server will not decorate requests with cookie manager |
handle |
function |
Type:
- object
EXTENSIONS :ResourcesExtensions
- Source:
Type:
logger :LoggerBuilder
- Source:
Type:
MAX_POST_SIZE :number
- Source:
default value is 16 Kb
ยป 16 * 1024
Type:
- number
mountPath :string
- Source:
Type:
- string
NodeJsMvc :SGAppsServer.NodeJsMvc
Type:
SessionManager :SGAppsSessionManager
Type:
shared :SGAppsServerShared
- Source:
Type:
STATUS_CODES :Object.<number, string>
- Source:
Type:
- Object.<number, string>
TemplateManager :TemplateManager
Type:
whenReady :Promise.<SGAppsServer>
- Source:
Type:
- Promise.<SGAppsServer>
Methods
all(path, …handlers) → {SGAppsServer}
- Source:
add handler to all methods
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
connect(path, …handlers) → {SGAppsServer}
- Source:
The CONNECT
method establishes a tunnel to the server identified by the target resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
delete(path, …handlers) → {SGAppsServer}
- Source:
The DELETE
method deletes the specified resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
Email(config) → {SGAppsServerEmail}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
config |
SGAppsServerEmail.Config |
Returns:
- Type
- SGAppsServerEmail
finalHandler(path, …handlers) → {SGAppsServer}
- Source:
add final handler to all methods, last added is first
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
get(path, …handlers) → {SGAppsServer}
- Source:
The GET
method requests a representation of the specified resource. Requests using GET should only retrieve data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
handle(request, response, callbackopt)
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
request |
IncomingMessage | ||
response |
ServerResponse | ||
callback |
SGAppsServerDictionaryRunCallBack |
<optional> |
handleErrorRequest(request, response, erropt)
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
request |
SGAppsServerRequest | ||
response |
SGAppsServerResponse | ||
err |
Error |
<optional> |
handlePostData(optionsopt) → {SGAppsServerHandlerPostData}
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
Returns:
handleRequest(request, response, callback)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
request |
SGAppsServerRequest | |
response |
SGAppsServerResponse | |
callback |
SGAppsServerDictionaryRunCallBack |
handleStaticRequest(request, response, path, callback, optionsopt)
- Source:
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
SGAppsServerRequest | |||||||||||||||||
response |
SGAppsServerResponse | |||||||||||||||||
path |
string | |||||||||||||||||
callback |
SGAppsServerErrorCallBack | |||||||||||||||||
options |
object |
<optional> |
Properties
|
head(path, …handlers) → {SGAppsServer}
- Source:
The HEAD
method asks for a response identical to that of a GET request, but without the response body.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
options(path, …handlers) → {SGAppsServer}
- Source:
The OPTIONS
method is used to describe the communication options for the target resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
patch(path, …handlers) → {SGAppsServer}
- Source:
The PATCH
method is used to apply partial modifications to a resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
post(path, …handlers) → {SGAppsServer}
- Source:
The POST
method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
put(path, …handlers) → {SGAppsServer}
- Source:
The PUT
method replaces all current representations of the target resource with the request payload.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
server() → {Server}
- Source:
Returns:
- Type
- Server
trace(path, …handlers) → {SGAppsServer}
- Source:
The TRACE
method performs a message loop-back test along the path to the target resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
RequestPathStructure | ||
handlers |
RequestHandler |
<repeatable> |
Returns:
- Type
- SGAppsServer
use(path, …handlersopt) → {SGAppsServer}
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | RequestHandler | ||
handlers |
RequestHandler |
<optional> <repeatable> |
Returns:
- Type
- SGAppsServer