A different kind of web framework.
npm install @liquicode/serverkitbash
npm install @liquicode/serverkit
`
`javascript
// Include the library into your project
const ServerKit = require( '@liquicode/serverkit' );
// Set some configuration options.
let server_options = {
AppInfo: {
environment: "development"
},
Transports: {
Web: {
ServerAddress: {
port: 4200
}
}
};
// Create a new server by supplying the Server's name, the Application Folder, and some settings.
let server = ServerKit.NewServer( 'MyServer', __dirname, server_options );
// - The server is created.
// - Configuration Defaults and Settings have been calculated.
// - No Services or Transports have been initialized.
// Initialize the server
await server.Initialize();
// - Services and Transports are initialized.
// - Services and Transports are ready for internal consumption.
// Start the server
await server.Startup();
// - Services and Transports are started.
// - Services can be called remotely via Transports (e.g. Web, WebSocket).
// Wait for some signal to stop the server ...
// Stop the server
await server.Shutdown();
`
ServerKit as an Application
You can run ServerKit as an application to publish your custom services.
Your service and configuration files will exist within the Application Folder:
~~~
~/MathsServer <-- Application Folder
MathsServer.options.json <-- Server Options (js or json)
MathsService.js <-- Custom Service
~~~
Run using NPX:
`bash
npm install @liquicode/serverkit
npx serverkit --name MathsServer --folder ~/MathsServer --options MathsServer.options.js
`
Run without Installation:
`bash
npx @liquicode/serverkit --name MathsServer --folder ~/MathsServer --options MathsServer.options.js
`
Run as a Docker Container:
`bash
docker run --mount type=bind,source=~/MathsServer,target=/server agbowlin/serverkit --name MathsServer --folder /server
^ use the ~/MathsServer folder ^ image name ^ serverkit arguments
`
ServerKit Features
---------------------------------------------------------------------
Server Features
- Create a new working server in minutes.
- The Server lifecycle is controlled entirely by your application.
- Ships with the Authentication service to handle user logins and sessions.
- Ships with the ServerAccounts service to manage user accounts.
- Authorize user access (via user roles) on a per-function basis.
- Ships with the Web transport for http based communication.
- The Web transport has Service Views which are like paramterized web pages.
- Support for popular templating view engines (pug, jade, ejs).
- Service Views can access user and application info from within the template.
- Ships with the WebSocket transport for communication utilizing web sockets.
- Ships with the Amqp transport for communication utilizing a message queue.
- Storage Services offer a user-based storage system that handles data ownership and sharing for you.
- Supports various storage mechanisms available to fit different scenarios (memory, local, remote).
- Full CLI support allows your services to be usable from the command line.
- ... virtually every aspect of ServerKit is controlled by configuration settings.
- ... all with copious and verbose logging (also configurable).
Development Features
Reusability
Once a ServerKit service authored, it can be used anywhere.
- Develop your application services as reusable components and let ServerKit handle the rest.
- Services are self-contained js files that can be managed seperately from the core server code (i.e. ServerKit).
- Once a service is written, it can be used with any transport (Text, Web, etc.) and in any scenario.
- A service can easily be copied to and used by another ServerKit project.
Security
ServerKit has a system of users and user roles which control access to service calls.
- Each service endpoint defines which user roles can call it.
- Each service endpoint defines which transport "verbs" it will be callable from (e.g. http-get, socket-call, etc.).
- Removes most, if not all, of the overhead concerning user management, authentication, etc.
- Predefined user roles admin, super, user, and anon.
Versatility
ServerKit ships with transports that allow your services to be called from various platforms.
- Use the Text transport to debug and test your services from the command line.
- Use the Text transport to develop a CLI for your services.
- Use the Web transport to develop http-based API servers.
- Use the Web and WebSocket transports to develop dynamic websites.
- Use the Amqp transport to invoke long running tasks (e.g. data backup).
Storage
The StorageService base class handles CRUD operations for user-owned data.
- Every data item is owned by a user so its like each user has their own database.
- End users can share data items to other users.
- Use MongoDB-like query criteria to access and manipulate user data.
- Storage providers are available for memory, local, and remote storage.
Configuration
ServerKit has a flexible and hierarchical configuration system.
- Store your configuration settings in configuration files and/or modify them in code.
- All configuration settings have sensible defaults, change only what you need.
- Configuration files can be independently managed for different environments (development, production, etc.).
- Configuration can also be modified in code.
User Interface
The ServerKit Web transport has a View Core feature to give you a fully functioning user interface for your services.
- Login and Signup pages
- Generic List and Item pages to perform all CRUD for a StorageService` based service.