README
Apache API
A simple Apache wrapper for Node.js.
API Reference
Initialization
You can itialize the API with a special Apache path:
const apacheApi = require('apache-api')('/usr/share/apache2/');
Or with the default one (/etc/apache2/
):
const apacheApi = require('apache-api');
Parser
Functions to parse and serialize an Apache configuration file.
const { parser } = require('apache-api');
object
parser.parse(content, [skipComments]): Parse an Apache configuration file.
| Param | Type | Description |
| --- | --- | --- |
| content | string
| Apache configuration file to parse |
| [skipComments] | boolean
| Wether ignore comments. Default: false
|
string
parser.serialize(content, [ident], [extendedSpaces]): Serialize an Apache configuration file.
| Param | Type | Description |
| --- | --- | --- |
| content | object
| Configuration object to serialize |
| [ident] | string
| Indent type. Default: two space |
| [extendedSpaces] | boolean
| Add more line returns between instructions. Default: false
|
Actions
Show Apache status, start, stop, and restart Apache service with systemctl.
const { actions } = require('apache-api');
Promise<any>
actions.start(): Start Apache service.
Promise<any>
actions.stop(): Stop Apache service.
Promise<any>
actions.restart(): Restart Apache service.
Promise<string>
actions.status(): Returns a promise with the Apache service status.
Mods
const { mods } = require('apache-api');
Promise<string[]>
mods.listAvailable(): Show available Apache mods.
Promise<string[]>
mods.listEnabled(): Show enabled Apache mods.
Promise<any>
mods.enable(mod): Enable an Apache mod.
| Param | Type | Description |
| --- | --- | --- |
| mod| string
| Mod to enable |
Promise<any>
mods.disable(mod): Disable an Apache mod.
| Param | Type | Description |
| --- | --- | --- |
| mod| string
| Mod to disable |
Configs
const { configs } = require('apache-api');
Promise<string[]>
configs.listAvailable([sites]): Show available Apache configs.
| Param | Type | Description |
| --- | --- | --- |
| sites | boolean
| Wether to list sites folder |
Promise<string[]>
configs.listEnabled([sites]): Show enabled Apache configs.
| Param | Type | Description |
| --- | --- | --- |
| sites | boolean
| Wether to list sites folder |
Promise<any>
configs.enable(config, [sites]): Enable an Apache config.
| Param | Type | Description |
| --- | --- | --- |
| config | string
| Config to enable |
| sites | boolean
| Wether to enable sites folder |
Promise<any>
configs.disable(config, [sites]): Disable an Apache config.
| Param | Type | Description |
| --- | --- | --- |
| config | string
| Config to disable |
| sites | boolean
| Wether to disable sites folder |
Promise<object|string>
configs.readConfig(config, [sites], [parseContent]): Read and parse (optional) a config.
| Param | Type | Description |
| --- | --- | --- |
| config | string
| Config to read |
| sites | boolean
| Wether to use sites folder |
| parseContent | boolean
| Wether to parse content |
Promise<any>
configs.saveConfig(config, [sites], [fromParsed]): Parse (optional) and save a config.
| Param | Type | Description |
| --- | --- | --- |
| config | object|string
| Config to save |
| sites | boolean
| Wether to use sites folder |
| fromParsed | boolean
| Wether to parse content |