Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@backstage/plugin-user-settings-backend
Advanced tools
The Backstage backend plugin to manage user settings
This backend allows to save user specific settings. All requests need to be
authorized, as the user identifier (userEntityRef
) is resolved using the
authorization token.
# From your Backstage root directory
yarn --cwd packages/backend add @backstage/plugin-user-settings-backend
userSettings.ts
file in
packages/backend/src/plugins/
:// packages/backend/src/plugins/userSettings.ts
import { createRouter } from '@backstage/plugin-user-settings-backend';
import { PluginEnvironment } from '../types';
export default async function createPlugin(env: PluginEnvironment) {
return await createRouter({
database: env.database,
identity: env.identity,
});
}
packages/backend/src/index.ts
: // packages/backend/src/index.ts
+import userSettings from './plugins/userSettings';
async function main() {
+ const userSettingsEnv = useHotMemoize(module, () => createEnv('user-settings'));
const apiRouter = Router();
+ apiRouter.use('/user-settings', await userSettings(userSettingsEnv));
}
To make use of the user settings backend, replace the WebStorage
with the
UserSettingsStorage
by using the storageApiRef
.
// packages/app/src/apis.ts
import {
AnyApiFactory,
createApiFactory,
+ discoveryApiRef,
+ fetchApiRef,
errorApiRef,
+ identityApi,
+ storageApiRef,
} from '@backstage/core-plugin-api';
+import { UserSettingsStorage } from '@backstage/plugin-user-settings';
export const apis: AnyApiFactory[] = [
+ createApiFactory({
+ api: storageApiRef,
+ deps: {
+ discoveryApi: discoveryApiRef,
+ errorApi: errorApiRef,
+ fetchApi: fetchApiRef,
+ identityApi: identityApiRef
+ },
+ factory: deps => UserSettingsStorage.create(deps),
+ }),
];
Use yarn start
to start the local dev environment. To simplify the access to
the API, the token will automatically be set to user:default/john_doe
.
You can change the user by setting a custom Authorization
header. To keep
things simple, the raw Bearer
value will directly be used as user.
Example:
curl --request GET 'http://localhost:7007/user-settings' --header 'Authorization: Bearer user:default/custom-user'
FAQs
The Backstage backend plugin to manage user settings
The npm package @backstage/plugin-user-settings-backend receives a total of 1,441 weekly downloads. As such, @backstage/plugin-user-settings-backend popularity was classified as popular.
We found that @backstage/plugin-user-settings-backend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.