Settings Guide

OS.js provides options for customizing the settings storage.

Two adapters are provided by default:

  • localStorage (in-browser, default)
  • server (via server)

Configuring adapter

See official resource list for provided adapter.

The README file of the module should provide more specific examples.

See provider guide for more information about provider setup.

Client

osjs.register(SettingsServiceProvider, {
  args: {
    adapter: 'server'
  }
});

Server

const customAdapter = require('custom-adapter');

osjs.register(SettingsServiceProvider, {
  args: {
    adapter: customAdapter
  }
});

Storing on filesystem

You can use the provided 'fs' adapter to store settings on a filesystem:

Settings are stored in home:/.osjs/settings.json by default.

// client
osjs.register(SettingsServiceProvider, {
  args: {
    adapter: 'server'
  }
});

// server
osjs.register(SettingsServiceProvider, {
  args: {
    adapter: 'fs',
  }
});

Configure adapter settings

The config parameter is passed on from your service provider registration:

osjs.register(SettingsServiceProvider, {
  args: {
    adapter: customAdapter
    config: { /* Your configuration here */}
  }
});

If you have sensitive information in your configuration, consider using dotenv.

OS.js Web Desktop - © Anders Evenrud <andersevenrud@gmail.com>

results matching ""

    No results matching ""