This is the bootstrap of the backend application.
The backend application is a server exposing the API of the editor library, by using JSON-RPC communication.
The files in this folder are used only to launch the server, while node_modules
contains the whole editor library - which for now is split in two: a custom standard library and the editor library itself.
README.md
: this current file.gitignore
: Git related file
Application:
index.js
: server bootstrapnode_modules
: the editor library
Server related:
routes.js
: the list of routes for the serveroptions.js
: the options to pass to the serverlogger.js
: defines a unique logger to be used throughout the whole applicationlog.log
: the logs of the application
To ignore:
log.log
: persistent file generated/altered at runtime, relevant only for production, not development
To version: everything else.
The application aims at providing source code edition services, independent of any user interface.
As all the actual functionalities are implemented in the editor library
, we'll describe here only what is done to serve its API.
In short, a custom RPC protocol is used, over HTTP, using JSON for data serialization.
The modules behind the API exposed by the server are all stored in the modes
module: once again, please refer to its documentation.
All of this is implemented by simply using a standard server library, currently directly embedded and developed in the editor library itself. Please refer to its documentation for any information on how to use it.
The Route is a common concept in HTTP servers: they define actions to be performed by the server based on some criteria concerning the requests it receives (like the URL path, the HTTP method, ...)
For more information about the implementation of the routes in the standard library, please refer to the server
module.
The server instance accepts a list of routes as inputs: these are defined in the routes module file, which exports an array collection of route specifications.
General options for the server.
Please refer to the server
module for more information on available options.
Options used here are defined in the options module file (for convenience), which directly an object that follows the input format that the server library expects.
DISCLAIMER: section to be reviewed
You can setup a unique logger for the whole application in the logger module file.
This module must export an instance of a logger, that is an object which must repect the following interface:
Methods:
info
log
error
warn
Services are actions performed on requests.
As previously stated, requests are handled by routes, and here we'll consider one service per request, so per route.
Standard service provided by the server library: documentation
Standard service provided by the server library: documentation
DISCLAIMER: make it a standard service of the server library
The /80d007698d534c3d9355667f462af2b0
route sends the content e531ebf04fad4e17b890c0ac72789956
.
This is generally used to identify the server as being an instance of this backend. Indeed, there is a very low probability (which could be calculated) to encounter the same context with another server:
- port
- protocol handled: HTTP
- request type: POST
- route/response pair: using only one GUID introduces already a high level of collision avoidance, but using a pair of that is even FAR higher
Standard service provided by the server library: documentation
For now there is only one module registered for exposition through RPC: the editor module. Please refer to the respective documentation for more information.
DISCLAIMER: not implemented by the library yet.
Standard service provided by the server library: documentation
With Node.js installed globally, launch the index
file with the following command:
node index
You can tweak the options
file, but take care about versioning issues behind.
Improve the logging system.
- choose where to put the logs: depending on the current working directory (current solution) or more deterministic? Giving the user an option would be good too.
- Learn how to use the library winston, configure it more.
- Find how to use the logger more globally, in other submodules.
Remove the old logging system used in routes.