npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

symeo-js

v0.0.13

Published

<h1 align="center"> <a href="https://app.symeo.io/"> <img width="300" src="https://s3.eu-west-3.amazonaws.com/symeo.io-assets/symeo-logo.png" alt="symeo"> </a> </h1> <p align="center"> <p align="center">Secret management as code. Easy. Centralized. Se

Downloads

25

Readme

Symeo JS SDK

The Symeo SDK made for interacting with your Symeo secrets and configuration from JavaScript or TypeScript applications.

Table of Contents

Install

NPM

npm install symeo-js --save 

Yarn

yarn add symeo-js

Usage

Define configuration contract

Create a symeo.config.yml file in the root of your project, and define the structure and types of your application configuration.

For example:

database:
  host:
    type: string
  port:
    type: integer
  username:
    type: string
  password:
    type: string
    secret: true
  • You can nest properties to any depth level
  • Supported types are boolean, string, integer and float
  • Properties can be flagged with optional: true, or secret: true

Build your configuration to access it in your code

You can add a build configuration command to your package.json:

{
  "scripts": {
    "build:config": "symeo-js build"
  }
}

And then run npm run build:config or yarn build:config

Use your configuration anywhere in your code

Your configuration is then accessible with the import:

import { config } from '@symeo-sdk';

Or using require:

const { config } = require('@symeo-sdk');

For example:

import { config } from '@symeo-sdk';
import { Client } from "postgres";

export class DatabaseClient {
  private client: Client;

  constructor() {
    this.client = new Client({
      host: config.database.host,
      port: config.database.port,
      username: config.database.username,
      password: config.database.password,
    })
  }
}

Create your local configuration file

Create a symeo.local.yml file in the root of your project, defining the values matching your configuration contract.

For example:

database:
  host: "localhost"
  port: 5432
  username: "postgres"
  password: "XPJc5qAbQcn77GWg"

Wrap your application startup with the symeo command

This will trigger the rebuild of you configuration at each statup and inject values into your runtime.

In your package.json, replace for example:

{
  "scripts": {
    "start": "node dist/index.js"
  }
}

with:

{
  "scripts": {
    "start": "symeo-js start -- node dist/index.js"
  }
}

Or, directly from the command line:

node_modules/.bin/symeo-js start -- node dist/index.js

Start application with configuration from Symeo platform

After creating an environment and its api key in the Symeo platform, use this command in your package.json

symeo-js start --api-key $YOUR_ENVIRONMENT_API_KEY -- node index.js

Or, directly from the command line:

node_modules/.bin/symeo-js start --api-key $YOUR_ENVIRONMENT_API_KEY -- node index.js

So the sdk fetch the values for the given environment and starts your application with those values.

Follow the Symeo platform documentation for more details.

Check your configuration is valid

In your CI or CD pipeline, run:

symeo-js validate --api-key $YOUR_ENVIRONMENT_API_KEY

Which will check if the values filled in the Symeo platform comply with your contract.

Symeo CLI commands

symeo-js build

Build your typescript types from your contract file.

-c, --contract-file

The path to your configuration contract file. Default is symeo.config.yml.

-r, --force-recreate

By default, if contract stays identical, configuration won't be rebuilt to save time. Passing this option will force the rebuild of your configuration.

symeo-js start

Start your application with your configuration values, either read from a local file or fetched from the Symeo platform.

-c, --contract-file

The path to your configuration contract file. Default is symeo.config.yml.

-f, --values-file

The path to your local values file. Default is symeo.local.yml.

-k, --api-key

The environment api key to use to fetch values from Symeo platform. If empty, values will be fetched from local value file (symeo.local.yml by default). If specified, parameter -f, --values-file is ignored.

-a, --api-url

The api endpoint used to fetch your configuration with the api key. Default is https://api.symeo.io/api/v1/values.

-r, --force-recreate

By default, if contract stays identical, configuration won't be rebuilt to save time. Passing this option will force the rebuild of your configuration.

symeo-js validate

Check that with your configuration values, either read from a local file or fetched from the Symeo platform, match your contract.

-c, --contract-file

The path to your configuration contract file. Default is symeo.config.yml.

-f, --values-file

The path to your local values file. Default is symeo.local.yml.

-k, --api-key

The environment api key to use to fetch values from Symeo platform. If empty, values will be fetched from local value file (symeo.local.yml by default). If specified, parameter -f, --values-file is ignored.

-a, --api-url

The api endpoint used to fetch your configuration with the api key. Default is https://api.symeo.io/api/v1/values.