{"id":22080029,"url":"https://github.com/superfaceai/one-service","last_synced_at":"2025-06-15T21:38:29.927Z","repository":{"id":37821723,"uuid":"417951861","full_name":"superfaceai/one-service","owner":"superfaceai","description":"OneSDK accessible as GraphQL","archived":false,"fork":false,"pushed_at":"2023-07-19T11:31:07.000Z","size":472,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-09T01:44:51.462Z","etag":null,"topics":["api","graphql","integrations","typescript"],"latest_commit_sha":null,"homepage":"https://superface.ai","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/superfaceai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-16T21:23:53.000Z","updated_at":"2023-03-23T08:08:19.000Z","dependencies_parsed_at":"2024-11-30T23:22:13.398Z","dependency_job_id":null,"html_url":"https://github.com/superfaceai/one-service","commit_stats":{"total_commits":110,"total_committers":7,"mean_commits":"15.714285714285714","dds":0.4,"last_synced_commit":"103f398a5e06b947bb7cb03a8851bc8df6121ef8"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/superfaceai/one-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superfaceai%2Fone-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superfaceai%2Fone-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superfaceai%2Fone-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superfaceai%2Fone-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/superfaceai","download_url":"https://codeload.github.com/superfaceai/one-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superfaceai%2Fone-service/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260054011,"owners_count":22952007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","graphql","integrations","typescript"],"created_at":"2024-11-30T23:11:59.499Z","updated_at":"2025-06-15T21:38:29.899Z","avatar_url":"https://github.com/superfaceai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Website](https://superface.ai) | [Get Started](https://superface.ai/docs/getting-started) | [Documentation](https://superface.ai/docs) | [Twitter](https://twitter.com/superfaceai) | [Support](https://superface.ai/support)\n\n\u003cimg src=\"https://github.com/superfaceai/one-service/raw/main/docs/LogoGreen.png\" alt=\"Superface\" width=\"100\" height=\"100\"\u003e\n\n# OneService\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/superfaceai/one-service/main.yml?branch=main)](https://github.com/superfaceai/one-service/actions/workflows/main.yml)\n[![npm](https://img.shields.io/npm/v/@superfaceai/one-service)](https://www.npmjs.com/package/@superfaceai/one-service)\n[![license](https://img.shields.io/npm/l/@superfaceai/one-service)](LICENSE)\n![TypeScript](https://img.shields.io/static/v1?message=TypeScript\u0026\u0026logoColor=ffffff\u0026color=007acc\u0026labelColor=5c5c5c\u0026label=built%20with)\n[![GitHub Discussions](https://img.shields.io/github/discussions/superfaceai/.github?logo=github\u0026logoColor=fff)](https://github.com/orgs/superfaceai/discussions)\n\nOneService allows you to run [OneSDK](https://github.com/superfaceai/one-sdk-js) as a service with configured usecases. And use it as [backend for frontend](https://samnewman.io/patterns/architectural/bff/).\n\nFor more details about Superface visit [how it works](https://superface.ai/how-it-works) and [get started](https://superface.ai/docs/getting-started).\n\n## Install\n\nYou can use this package as a globally installed CLI program:\n\n```shell\nnpm install --global @superfaceai/one-service\n```\n\n## Usage\n\nTo run OneService you need to have Superface configuration.\n\n1. Create new folder where the configuration will be created:\n\n   ```shell\n   mkdir myapp\n   cd myapp\n   ```\n\n2. [Install usecases](https://superface.ai/docs/getting-started#install-the-capability) and [configure providers](https://superface.ai/docs/getting-started#configure-the-provider) \u003ca name=\"usage-install-profiles\"\u003e\u003c/a\u003e:\n\n   ```shell\n   npx @superfaceai/cli install weather/current-city --providers wttr-in\n   ```\n\n   (Repeat for any usecase you find in [Catalog](https://superface.ai/catalog).)\n\n3. Start OneService with [GraphiQL](https://github.com/graphql/graphiql).\n\n   ```shell\n   oneservice --graphiql\n   ```\n\n4. Visit http://localhost:8000/ to open GraphQL interactive IDE\n\n### Use as a HTTP server middleware\n\nOneService package provides `createGraphQLMiddleware` function for mounting the GraphQL server as a middleware with any HTTP web framework that supports connect styled middleware. This includes [Connect](https://github.com/senchalabs/connect) itself, [Express](https://expressjs.com/), [Polka](https://github.com/lukeed/polka), [Restify](http://restify.com/) and others.\n\nThe `createGraphQLMiddleware` function returns a promise, therefore you need to await resolution before mounting the middelware.\n\nIf you can use [ES modules](https://nodejs.org/api/esm.html) in your project, you can resolve the promise with top-level `await`:\n\n```js\n// server.mjs\nimport express from 'express';\nimport { createGraphQLMiddleware } from '@superfaceai/one-service';\n\nconst app = express();\nconst graphqlMiddleware = await createGraphQLMiddleware({\n  graphiql: true,\n});\n\napp.use('/graphql', graphqlMiddleware);\n\napp.listen(3000);\n```\n\nAlternatively you can setup the server inside an `async` funtion:\n\n```js\nconst express = require('express');\nconst { createGraphQLMiddleware } = require('@superfaceai/one-service');\n\nasync function startServer() {\n  const app = express();\n  const graphqlMiddleware = await createGraphQLMiddleware({\n    graphiql: true,\n  });\n  app.use('/graphql', graphqlMiddleware);\n\n  app.listen(3000);\n}\n\nstartServer();\n```\n\n`createGraphQLMiddleware` function will throw an error if it cannot generate a GraphQL schema. Possible issues include:\n\n- missing or invalid `super.json`\n- name collision between use-cases of installed profiles\n- profile with features unsupported by GraphQL\n\n## Example Queries\n\n```graphql\nquery WeatherInPrague {\n  WeatherCurrentCity {\n    GetCurrentWeatherInCity(input: { city: \"Prague\" }) {\n      result {\n        temperature\n        feelsLike\n        description\n      }\n    }\n  }\n}\n\nquery SelectProvider {\n  WeatherCurrentCity {\n    GetCurrentWeatherInCity(\n      input: { city: \"Prague\" }\n      provider: { mock: { active: true } } # active flag is optional if only one provider is configured\n    ) {\n      result {\n        temperature\n        feelsLike\n        description\n      }\n    }\n  }\n}\n\nquery InstalledProfilesAndProviders {\n  _superJson {\n    profiles {\n      name\n      version\n      providers\n    }\n    providers\n  }\n}\n```\n\n### Use with `.env` file\n\nOneService doesn't automatically load `.env` file. You can manually use [dotenv package](https://github.com/motdotla/dotenv) for this functionality. If you would like to use OneService CLI with dotenv, follow these steps:\n\n1. Install dotenv and OneService locally in your project:\n\n   ```\n   npm i dotenv @superfaceai/one-service\n   ```\n\n2. Run the CLI via `node` with [dotenv preload](https://github.com/motdotla/dotenv#preload):\n\n   ```\n   node -r dotenv/config node_modules/.bin/oneservice\n   ```\n\n## Deployment\n\n### Considerations\n\nOneService doesn't provide any authentication or CORS support.\nThis should be handled by API Gateway (eg. [Express Gateway](https://github.com/ExpressGateway/express-gateway) or [Kong](https://github.com/kong/kong)) or you can use own Express instance and [attach the middleware](#use-as-http-server-middleware).\n\n### Heroku\n\nOneService can be deployed to [Heroku with Git](https://devcenter.heroku.com/articles/git).\n\n#### Prerequisites\n\n- [Heroku CLI installation instructions](https://devcenter.heroku.com/articles/heroku-cli#download-and-install)\n- [Git installation instructions](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)\n- [Node.js installation instructions](https://nodejs.dev/learn/how-to-install-nodejs)\n\n#### Steps\n\n1. You will need folder for the application with local Git repository\n\n   ```shell\n   mkdir myapp\n   cd myapp\n   git init\n   ```\n\n2. Next step is to install OneService\n\n   ```shell\n   npm init -y\n   npm install --save @superfaceai/one-service\n   ```\n\n3. Install profiles as explaied in [Usage step 2](#usage-install-profiles).\n\n4. [Create Heroku Procfile](https://devcenter.heroku.com/articles/procfile)\n\n   ```shell\n   echo 'web: oneservice --port $PORT --host 0.0.0.0 --graphiql --logs' \u003e Procfile\n   ```\n\n5. Commit changes to Git repository\n\n   ```shell\n   git add --all\n   git commit -m 'OneService configuration'\n   ```\n\n6. Create Heroku remote\n\n   ```shell\n   heroku create\n   ```\n\n7. Deploy app\n\n   ```shell\n   git push heroku main\n   ```\n\n## Logs\n\nOneService can print structured logs. To allow it use `--logs=\u003clevel\u003e` flag:\n\n```shell\noneservice --logs\noneservice --logs=trace\n```\n\nSet the optional logging level specifier. Available levels are (ordered by priority):\n\n- fatal\n- error\n- warn\n- info\n- debug\n- trace\n- silent\n\nThe logging level is the __minimum__ threshold. When set, every higher level will be logged as well. For instance if `logger.level` is `info` then all `fatal`, `error`, `warn`, and `info` logs will be enabled.\n\nYou can pass `silent` to disable logging.\n\n### Pretty print\n\nTo print structured logs in readable way during testing or developement, you can use [pino-pretty](https://www.npmjs.com/package/pino-pretty).\n\nInstall `pino-pretty`:\n\n```shell\nnpm install -g pino-pretty\n```\n\nRun OneService with pretty print:\n\n```shell\noneservice --logs=trace | pino-pretty\n```\n\n## Contributing\n\nWe welcome all kinds of contributions! Please see the [Contribution Guide](CONTRIBUTING.md) to learn how to participate.\n\n## License\n\nOneService is licensed under the [MIT License](LICENSE).\n\n© 2023 Superface s.r.o.\n\n\u003c!-- TODO: allcontributors --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperfaceai%2Fone-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuperfaceai%2Fone-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperfaceai%2Fone-service/lists"}