Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@foundry-ai/foundry-service-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foundry-ai/foundry-service-loader

A lazy service loader for Foundry.ai projects

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Foundry Service Loader

Doc Sections
Getting Started
Included Services
Making Changes

Get the Code

Usage

1. Require

const FoundryServiceLoader = require('foundry-service-loader');
// Easy enough

2. Init

const serviceLoader = FoundryServiceLoader(config);
 // see README.md in config folder

3. Usage

const myService = new MyService();
serviceLoader.setService('myService', myService);

// later on in another file
const serviceLoader = require('foundry-service-loader')(); // no need to pass config in again after init
const myService = serviceLoader.getService('myService');

Included Services

ElasticSearch Client

const Config = require('config');
const FoundryServiceLoader = require('foundry-service-loader');
const serviceLoader = FoundryServiceLoader(Config.get('services'))
const elasticSearchClient = serviceLoader.getElasticSearchClient();

// use the service
return new Promise((resolve, reject) => {
  elasticSearchClient.indices.create({
    index: 'myIndexName'
  }, (err, result) => {
    if (err) reject(err);
    else resolve(result);
  })
})

Email

const Config = require('config');
const FoundryServiceLoader = require('foundry-service-loader');
const serviceLoader = FoundryServiceLoader(Config.get('services'))
const emailService = serviceLoader.getEmailService();

// use the service
emailService.send(emailData)
.then(authorization => { /** do something */ })
.catch(err => { /** handle error */ });

Foundry Kue Scheduler

Logger

const Config = require('config');
const FoundryServiceLoader = require('foundry-service-loader');
const serviceLoader = FoundryServiceLoader(Config.get('services'))
const logger = serviceLoader.getLogger();

// use the service
logger.info('My info log', { data })

Making Changes

If you have never used Git, search around online to get a grounding. But here are the basic commands you will need to use to actually push code to our repository, with a little bit of Git theory to explain what's going on.

  1. First make sure you have the most current version of the codebase. In your terminal window, navigate to the project root. Type git checkout master to checkout the master branch.
  2. git pull origin master will update master with any new changes.
  3. git checkout -b feature/[NEW_FEATURE_NAME] this will create a new branch (called feature/NEW_FEATURE_NAME, or whatever you want). Your branch names should be descriptive, but short. For example, if I want to create a cart on my branch, I might call it "feature/cart" (after the object) or "feature/checkout" (after the functionality).
  4. You can run git branch at any time to see which branch you're on and what branches you have locally.
  5. Write some code. If you ever want to see which files you've changed, added, or deleted you can run git status
  6. When you are satisfied with your changes, make a commit by executing git commit -am [YOUR_COMMIT_MESSAGE]. The -a attribute tells Git to commit all changed files. If you don't want to commit all of them, you'll have to type the names of the files. The -m is required; Git needs commit messages. Try to be descriptive, maybe your first commit message will be "store skeleton", the next will be "product page", etc. NOTE git commit -a will not commit any new files since they are not part of Git yet. If you have new files you will need to run git add . before the above commands ("." means "all").
  7. Once the code is committed to your branch, your branch is ready to go. Now we just need to release it into the internet and tell everyone else that we want to combine this branch with the master branch. Execute git push origin [BRANCH_NAME]. Here, origin represents our Bitbucket repository. Run git remote -v to see your repository aliases.
  8. Now we create a pull request on github - in other words, a request to the other developers that we want our code to be merged into the application. In the left sidebar, click Pull Requests > Create Pull Request. The branch on the left should be the branch you were just working on i.e. the one we want to merge into the app. The branch on the right should be master. Make a descriptive title so we know what the pull request is for, and add the necessary reviewers.
  9. Click "Create Pull Request" and wait for us to review your code.

We follow the git branching model outlined in this blog post.

Keywords

FAQs

Package last updated on 25 Apr 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc