Skip to content

Files

Latest commit

 

History

History
80 lines (58 loc) · 1.53 KB

README.md

File metadata and controls

80 lines (58 loc) · 1.53 KB
description full_title
A guide on customizing settings adapters
Settings Guide

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.